Example:
Copy Code code as follows:
Response.Cookies ("Letwego") ("visiter") = "84WW" ' Assignment
Response.Cookies ("Letwego"). Expires= (now () 7) ' Set Expiration Time (7 days)
Username=request.cookies ("Letwego") ("Visiter") ' Take Cookies
Response.Cookies ("Letwego"). Expires= (Now ()-1) ' Delete cookies, set expiration time (-1 days)
' DateAdd ("n", 30,now ()) Get minutes
' DateAdd ("S", 30,now ()) Get seconds
First, read
Copy Code code as follows:
Response.Cookies ("visiter") = "AAA"
A=request.cookies ("Visiter")
Response.Cookies ("Letwego") ("visiter") = "AAA"
A=request.cookies ("Letwego") ("Visiter")
second, set the expiration time
Response.Cookies ("Visiter"). Expires=dateadd ("H", 8,now ()) ' means Cookies kept for 8 hours
Response.Cookies ("user_name"). Expires=date 1 ' Specify Cookie save time
Keep cookies for one hours
Response.Cookies ("MyCookie"). Expires= (now () 1/24)
Response.Cookies ("MyCookie"). Expires = DATEADD ("h", 1, Now ())
Response.Cookies ("CookieName"). Expires=dateadd ("M", 60,now ())
Set expires after 60 months
Response.Cookies ("User"). Expires=second () 7
The time defined after expires can be replaced with a time function
For example: Date () 7 means adding 7 days to today's time, and second () 7 is 7 seconds.
Response.Cookies ("field name"). expires= time function N, for example:
Response.Cookies ("Name2"). Expires=date 1, which means that Cookies are kept for 1 days, and then for example:
Response.Cookies ("Name2"). Expires=hour 8, which means Cookies are kept for 8 hours.
I have not tested this method (in 2003server,iis6.0), regardless of the second after the addition (), access to a 500 error (or the page can not be displayed?) Forgotten).
The time added here is to use the DATEADD function, for example, if we add an hour, we use:
Response.Cookies ("Baidooglecom"). Expires = DATEADD ("h", 1, Now ())
30 minutes:
Response.Cookies ("CookieName"). Expires=dateadd ("n", 30,now ())
DATEADD ("S", 30,now ()) Get seconds
EXPIRES Specifies the expiration date for the cookie. In order to store cookies on the client disk after the session is over, or at many times, we want to save cookies on the visitor's computer for a long time. The date must be set.
If the setting for this property does not exceed the current date, the cookie expires after the task ends.
The use of the cookie expires with "January 1, 2010": Response.Cookies ("CookieName"). expires= #January 01, 2010#
The expiration time for the cookie is "cookie creation time + 365 days": Response.Cookies ("CookieName"). Expires=date 365 recommended.
But it's best not to write Response.Cookies ("CookieName") casually. Expires=date, so that the call value between pages is empty.