faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

101 of 112 people (90%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

How can I set a cookie so that it never expires?

Jul 6th, 2004 03:56
Deepak Bansal, Rachit Bagda, unknown unknown, http://www.rachit.com http://www.rtnaustralia.com http://www.rtnasia.com


There's no way you can set a cookie to NEVER expire - but what you can 
do is to set the expiry date to several years ahead like "July 4, 
2010" 
:
   Response.Cookies("cookiename").Expires = "July 4, 2010"
If you're thinking "Hey, what if today's date IS July 3, 2021 - my 
cookie would expire tomorrow !!!". For this case, you can also use 
relative expiration dates by using the syntax Date + n where n is the 
number of days before expiring :
  Response.Cookies("cookiename").Expires = Date + 300
This will in effect extend the expiry date of the cookie to an 
additional 200 days from the time it was accessed.



© 1999-2004 Synop Pty Ltd