Cookie Trouble --> disappearing

D

dave

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
 
N

Natty Gur

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
 
L

Luke Zhang [MSFT]

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.)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,835
Latest member
KetoRushACVBuy

Latest Threads

Top