[thelist] ASP Newbie Cookie Timeout Probs

Lonnie Kraemer lwkraemer at earthlink.net
Wed Jan 29 13:01:19 CST 2003


> Hello all.  Can someone tell me how to make a cookie expire in ASP in
say 10 minutes instead of 1 day?  Below is the code that I am using..
> From what I have been able to find, you have to set the date and time
in the cookie.  Does that mean that I have to create a variable and
create my date/time and then put it in the Expires?
>
> Response.Cookies("sessCookTime") = "cookieName"
> Response.Cookies("sessCookTime").Domain = ".example.com"
> Response.Cookies("sessCookTime").Expires = Date + 1
> Response.Cookies("sessCookTime").Path = "/"
> Response.Cookies("sessCookTime").Secure = False

Chris,

There are two types of cookies - persistent and non-persistent (or
in-memory) cookies. For the former you set an expiration. This will
cause the cookie to be written to the users disk. For the latter, you
need only the first declaration, in which case the cookie will
automatically expire when the user closes his browser or, IIRC, when the
session times out. In either case, .Domain, .Path, .Secure are not
required.

That said, to expire a cookie in 10 minutes, you could simply use the
DateAdd method:
.Expires=DateAdd("n",10,Now)




More information about the thelist mailing list