How do you create a permanent cookie ?

 Posted by Bharathi Cherukuri on 5/21/2012 | Category: ADO.NET Interview questions | Views: 1516 | Points: 40

Setting a permanent cookie is similar to Session cookie, except giving the cookie an expiration date. 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())

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response