PDA

View Full Version : Cookies Expire


christrinder
04-14-2003, 09:04 AM
Hello,

Forgive me if I've misunderstood, but I was under the impression cookies were stored on the computer so that even if the session expired (i.e. when the window was closed), the cookie would hold the information for when the user returned? I've used the below cookie code and it works fine whilst navigating between pages, but if I close the window, then return, the cookie info has been lost. Any ideas?

Thanks,
Chris

Response.Cookies("franchiseid") = objRSlogin2("CompanyID")
Response.Cookies("franchiseid").Expires=#January 1,2004#

raf
04-14-2003, 09:48 AM
My first geuss would be that this is not the last cookieaction and that you reset the expire value later on.

I never use cookie and i'd never use fixed dates. If i did, i'd always use relative values for the expiredate (you know; Date + 365 ) if it need to be out there 1 year. (But that's just me)Else you'll need to fix your code continuesly ore need an extra asp command.

Try checking if the cookie still exists on you logout bij running a
request.cookies("franchiseid").haskeys
(if it returns True, then the qookie exists on logout)

Or it could just be the space between the comma and the year (there should be one)

christrinder
04-14-2003, 08:48 PM
Thanks Raf. I've messed around with it and it's working now. I think I might have spelt something wrong or some other rookie error. Will def use the date + 365 though... makes much more sense. I didn't know you could do that. Do I write it as:

date() + 365, or, now() + 365, or simply, date + 365?

Cheers,
Chris

raf
04-14-2003, 09:13 PM
your welcome.

Like i said, i never use cookies. But i looked it up in my book, and there its

Date + x

where x is the number of days.

cause i don't want to give you false info, i ran a quick search and here
http://www.4guysfromrolla.com/webtech/110299-1.shtml
they use Now() + x is they want to set a relative date. So i geus you can use all three.


I also saw that if the expire-date is not set correctly, the cookie is lost when the session ends, which kinda sounds like what you described

christrinder
04-15-2003, 09:02 AM
Thanks guys. I think I will stick with sessions but make the timeout variable longer. Do I need to declare the time.out for each individual session, or are all session variables grouped, hence requiring only one session.timeout statement. Does that make sense? I.e. which of the below is correct?

- - - - - - - - - - - -

Session("1")= objRS1("1")
Session.Timeout=60

Session("1") = objRS1("2")
Session.Timeout=60

- - - - - - - - - - - -

Session("1")= objRS1("1")
Session("1") = objRS1("2")
Session.Timeout=60

glenngv
04-15-2003, 09:41 AM
you don't have to declare session timeout for each session variable since when the session timeouts, all session variables are destroyed.