Could someone test this? It's driving me crazy.

Discussion in 'ASP .Net' started by Shapper, Apr 29, 2005.

  1. Shapper

    Shapper Guest

    Hello,

    I have this code in Global.asax:

    Sub Session_Start(Sender As Object, E As EventArgs)

    Dim cookie As HttpCookie = Request.Cookies("MyCookie")
    If Not cookie Is Nothing Then
    Response.Write(" * Cookie Exists * ")
    If Not cookie.Values("culture") Is Nothing
    Response.Write(" * Value Culture Exists Inside Cookie *
    ")
    Session("culture") = cookie.Values("culture")
    Thread.CurrentThread.CurrentCulture = New
    CultureInfo(cookie.Values("culture"))
    Else
    Response.Write(" * Value Culture Doesn't Exist Inside
    Cookie* ")
    cookie.Values.Add("culture", "pt-PT")
    Response.Cookies.Add(cookie)
    End If
    Else
    Response.Write(" * Cookie Doesn't Exist * ")
    Dim newCookie As HttpCookie = New
    HttpCookie("CamaraDosPares")
    newCookie.Values.Add("culture", "pt-PT")
    newCookie.Expires = #01/01/3000#
    Request.Cookies.Add(newCookie)
    End If

    End Sub

    Basicly this shoud work this way:

    IF Cookie Exists AND Cookie Value "Culture" Exists THEN

    Session("culture") = ...

    IF Cookie Exists AND Cookie Value "Culture" Doesn't Exist THEN

    Add Culture Value to the existing Cookie.
    (NOTE: Cookie have many other values. Culture Values must be
    added to the existing ones.)

    IF Cookie Doesn't Exist THEN

    Create Cookie and place a "culture" value inside it.


    Of course I want this code to run when a new session starts.

    The code works but strange things happen like:
    No Cookie is created.
    OR
    When Culture value is added to cookie all the other disappear.

    This is driving me crazy. I am on this for hours.
    Could someone please check it out?
    I added Response.Write commands to help following what is going on.

    Maybe something stange going on with my OS....I don't know.

    Thank You,
    Miguel
     
    Shapper, Apr 29, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William Gower

    ItemTemplate error driving me crazy

    William Gower, Apr 23, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    321
    William Gower
    Apr 23, 2004
  2. =?Utf-8?B?VGltOjouLg==?=

    Insert and Variables driving me crazy! Newbie...

    =?Utf-8?B?VGltOjouLg==?=, Dec 20, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    339
    =?Utf-8?B?VGltOjouLg==?=
    Dec 21, 2004
  3. Joe Blanchard via .NET 247
    Replies:
    1
    Views:
    764
    Eliyahu Goldin
    May 15, 2005
  4. David White
    Replies:
    0
    Views:
    369
    David White
    Jul 31, 2003
  5. Ishira
    Replies:
    4
    Views:
    400
    Kevin Goodsell
    Aug 1, 2003
Loading...

Share This Page