Cookies under 1 day does not work !

F

Fabrice Labrousse

Hello,

after many deep searches on javascript and cookies, i still cannot have an
answer for a incredible cookie problem !
here it is, i hope you'll be able to answer me :

This is my function that put on a disk a cookie that has a 5 minutes
duration


function pose_5minutescookie()
{
var expdate=new Date();
expdate.setTime(expdate.getTime() + (5 * 60 * 1000));
alert ("expires=" + expdate);
document.cookie = 'test=1; expires=' + expdate.toGMTString() + '; path=/;
domain=eg_domain';
window.history.go(0);
}

the alert says that the expiration date is well calculated
the cookie sets on the drive

BUT

The cookie never expires !!!!!!!!

Another interesting expérience is that if i change the time to less than 500
(ms that's right !) instead of 5 minutes (in the example), the cookie does
not appear on the disk. I think this should mean that its living time is too
short to be written. I admit but if i run this cookie to expire in 1000 ms,
it appears ont the disk but it never expire !

Any idée ? Did anybody ran a 5 minutes cookie ?

Fabrice
 
E

Erwin Moller

Fabrice said:
Hello,

after many deep searches on javascript and cookies, i still cannot have an
answer for a incredible cookie problem !
here it is, i hope you'll be able to answer me :

This is my function that put on a disk a cookie that has a 5 minutes
duration


function pose_5minutescookie()
{
var expdate=new Date();
expdate.setTime(expdate.getTime() + (5 * 60 * 1000));
alert ("expires=" + expdate);
document.cookie = 'test=1; expires=' + expdate.toGMTString() + ';
path=/;
domain=eg_domain';
window.history.go(0);
}

the alert says that the expiration date is well calculated
the cookie sets on the drive

BUT

The cookie never expires !!!!!!!!

Another interesting exp�ience is that if i change the time to less than
500 (ms that's right !) instead of 5 minutes (in the example), the cookie
does not appear on the disk. I think this should mean that its living time
is too short to be written. I admit but if i run this cookie to expire in
1000 ms, it appears ont the disk but it never expire !

Any id� ? Did anybody ran a 5 minutes cookie ?

Fabrice

Hi Fabrice,

I am not sure, but maybe it is this:

It depends on what you mean by 'never expires'?
If you mean that the coockiefile exists on disk. --> okay. You cannot expect
your browser to scan every possible cookie from every possible site every
millisecond to check if it should delete them, can you?

If you mean that you try to read the value of test 10 minutes later the
normal way (that is not looking at the file, but reading it using
javascript), and it still shows up. --> your browser is broken, or you made
some mistake in the setting/getting of the cookie.
Maybe you are setting the cookie every time again (with a timestamp of +5
minutes from now)
Hard to tell without the complete code/logic.

I expect a browser to update the coockie (and delete it) only when needed.

Hope this helps,
regards,
Erwin Moller
 
F

Fabrice Labrousse

Hello Erwin,

You were right, cookies are working fine. I was sure the cookie had to
disapear from the disk but it doesn't and anyway the cookie duration was ok.
Thank you very much for your help, i was stupidily stuck but you gave me the
idea i did not test.

Regards
Fabrice
"Erwin Moller"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top