By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,607 Members | 2,008 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,607 IT Pros & Developers. It's quick & easy.

Cookies under 1 day does not work !

P: n/a
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

Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Fabrice Labrousse wrote:
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
Jul 20 '05 #2

P: n/a
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"
<si******************************************@spam yourself.com> a écrit dans
le message de news: 40*********************@news.xs4all.nl...
Fabrice Labrousse wrote:
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

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.