[thelist] ASP: Cookie - expire
Anthony Baratta
Anthony at Baratta.com
Tue Jul 8 12:36:46 CDT 2003
At 07:06 AM 7/8/2003, Casey Crookston wrote:
>What do I need to do so that this cookie is a permanent one?
You need to set and expiration date. If you decline to set an expiration
date the cookie is treated as a session cookie.
response.cookies("CookieName").expires = Now() + 0.042 '' Approx One hour
expiration
At 11:26 PM 7/7/2003, Casey Crookston wrote:
>How do you set a cookie to expire when the user closes the browser, or in a
>half hour - which ever comes first?
Tie your cookie to the actual session object that IIS uses. This is a
session cookie with a timer for expiration.
Session("SessionName") = "Data"
Session.TimeOut = 30 '' Default is 20 Minutes
(This next statement might catch me some flack)
But if you are using IIS 5, I find it easier to stuff dictionary objects
into your session object:
Login Page:
If (LoginSuccessful) then
Set dictUserInfo = Server.CreateObject("scripting.dictionary")
dictUserInfo("FullName") = "Blah"
dictUserInfo("UserID") = "Blah"
dictUserInfo("OtherImportantInfo") = "Blah"
Set Session("SessionName") = dictUserInfo
response.redirect("/ProtectedPage.asp")
else
'' Try Again
end if
Check Login on every "protected" page
if isEmpty(SessionName) then
response.redirect("/LoginPage.asp")
else
Set dictUserInfo = Session("SessionName")
end if
--
Anthony Baratta
President
Keyboard Jockeys
"Conformity is the refuge of the unimaginative."
More information about the thelist
mailing list