How do you create a permanent cookie?

Showing Answers 1 - 3 of 3 Answers

Shobha

  • Sep 20th, 2005
 

Setting a permanent cookie is similar to Session cookie, except give the cookie an expiration date too. It is very common that you don't specify any arbitrary expiration date, but instead expire the cookie relative to the current date, using the DateAdd() function.

Response.Cookies("Name") = "myCookie"
Response.Cookies("Name").Expires = DateAdd("m", 1, Now())

  Was this answer useful?  Yes

Praveen Kumar

  • Feb 7th, 2006
 

Permanent cookies are available until a specified expiration date, and are stored on the hard disk.So Set the 'Expires' property any value greater than DataTime.MinValue with respect to the current datetime. If u want the cookie which never expires set its Expires property equal to DateTime.maxValue.

  Was this answer useful?  Yes

mrp100461

  • Aug 5th, 2009
 

<%
Response.Cookies("username") = "TEXT"
Response.Cookies("username").Expires = Date.MaxValue
%>


This is the best way because DateAdd is old VB, this can work in VB.Net and C# 

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions