Cookie Trouble --> disappearing

Discussion in 'ASP .Net' started by dave, Jul 3, 2003.

  1. dave

    dave Guest

    I have 2 pages... in the first page i check to see for
    the existance of the cookie, if found do something else
    set the value and set the cookie.
    (cookie gets set ok)

    I use the following code to read and write the cookie..
    READ..
    Dim stmp As String
    Dim c As HttpCookie =
    HttpContext.Current.Request.Cookies("HD")
    If Not c Is Nothing Then
    stmp = c(Key)
    Else
    stmp = ""
    End If
    Return stmp

    WRITE
    Dim c As New HttpCookie("HD")
    c("DialogTypeID") = DialogTypeID.ToString
    c.Expires = DateTime.Now.AddYears(1)
    HttpContext.Current.Response.Cookies.Add(c)



    Now i navigate to a second page which looks for a cookie
    of a differnt name and reads the value. The following
    code...

    Dim stmp As String
    Dim c As HttpCookie =
    HttpContext.Current.Request.Cookies("HD2")
    If Not c Is Nothing Then
    stmp = c(Key)
    Else
    stmp = ""
    End If
    Return stmp

    Now when i navigate back to the first page the first
    cookie is gone. I look in my localhost cookies and it is
    no longer in the cookie file. PLEASE tell me what is
    going on.

    please.
    thank you in advance...

    dave
     
    dave, Jul 3, 2003
    #1
    1. Advertising

  2. dave

    Natty Gur Guest

    Hi,

    if you dont set any of the cookies properties (Domain,Expires...) the
    default is that cookie will be available for the current page. if you
    navigate to other page the cookie die. when you use the Back button the
    browser use cache version of the page. no call is made to the server so
    no new cookie creat and the old one already vanished.

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Natty Gur, Jul 3, 2003
    #2
    1. Advertising

  3. DId you also "write" cookies in the second web form? Additionally, when
    will you write the cookies, after find that stmp is empty?

    Luke

    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
     
    Luke Zhang [MSFT], Jul 7, 2003
    #3
    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. Ben
    Replies:
    3
    Views:
    5,891
    Steven Cheng[MSFT]
    Jun 3, 2004
  2. Shapper

    Cookie and Session Cookie Questions.

    Shapper, Apr 27, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    586
  3. m

    disappearing cookie

    m, Jul 30, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    376
  4. =?Utf-8?B?UGF1bA==?=

    Cookie Question (IP as domain and cookie file location)

    =?Utf-8?B?UGF1bA==?=, Jan 10, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    2,499
    Bruce Barker
    Jan 10, 2006
  5. ad
    Replies:
    2
    Views:
    7,561
    Kevin Spencer
    Jan 27, 2006
Loading...

Share This Page