cookie expiry date problem

R

Ray

Below is the code to save the cookie and set the expiry date of the cooki

Response.Cookies["demo"].Value ="Hello"
DateTime dt = DateTime.Now
TimeSpan ts = new TimeSpan(0,0,10,0)
Response.Cookies ["demo"].Expires = dt.Add(ts);

Below is the code to retrieve the stored cookie

if (!Page.IsPostBack)
HttpCookie dcookie = Request.Cookies["demo"]
if (dcookie != null)
urlevel.Text = dcookie.Values["level"]
urname.Text = dcookie.Values["user"];
daysx.Text = Convert.ToString(Request.Cookies["demo"].Expires)

els
Response.Redirect ("haha.htm")


When I display the Response.Cookies ["demo"].Expires = dt.Add(ts); it returns the current date + 10 minute
But the days.Text returns 01/01/0001. Why? Please help Thanks

Ray
 

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,776
Messages
2,569,603
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top