How to set the lifetime for a cookie?

Tripati_tutu
Posted by Tripati_tutu under ASP.NET category on | Points: 40 | Views : 2703
Suppose you want to set the lifetime for a cookie in hours, then
CookieName.Expires = DateTime.Now.AddHours(5);
With the above code, the cookie will expire after exactly 5 hours.


Suppose you want to set the lifetime for a cookie in days, then
CookieName.Expires = DateTime.Now.AddDays(3);
With the above code, the cookie will expire after exactly 3 days.

Comments or Responses

Login to post response