Cookie's Expiration property unexpectedly changing

J

Jeff Bowman

Here's the code:

Private Sub SetCookie(ByVal tcEmail As String)
Dim loCookie As New HttpCookie("Email")
loCookie.Value = Utils.StringToBase64(tcEmail)
loCookie.Expires = Now.AddYears(10)
Response.Cookies.Add(loCookie)
End Sub

The cookie appears to accept the specified expiration date (i.e. #7/13/2015
10:18:21 PM#) just fine, but when I read the cookie in a new browser session its
Expiration property returns simply #12:00:00 AM#.

What happened to the date portion, and more importantly how can I get it back? I
need it so I can do calculations elsewhere in my code.

Many TIA for any suggestions,
Jeff
 
J

Jeff Bowman

OK, after a bit of a break to step away and clear my head a bit, I've concluded
that the value of a cookie's Expiration property isn't intended to be used in
any sort of server-side computation--it's for the browser's internal use only.

Armed with this new way of looking at things, I only had to change the way I was
doing my calculation. All is well now, and I can go to bed and rest peacefully.

Thanks for your ear!

Jeff
 
R

Robert Smith

The cookie appears to accept the specified expiration date (i.e. #7/13/2015
10:18:21 PM#) just fine, but when I read the cookie in a new browser session
its
Expiration property returns simply #12:00:00 AM#.

What happened to the date portion, and more importantly how can I get it
back? I
need it so I can do calculations elsewhere in my code.

Many TIA for any suggestions,
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top