...

View Full Version : cookie expiration...



d52477001
06-04-2003, 02:22 PM
hi,

i am using the following script to write a cookie:

<html>
<head>

<SCRIPT LANGUAGE="JavaScript"><!--
function Set_Cookie(name,value,expires,path,domain,secure) {
document.cookie = name + "=" +escape(value) +
( (expires) ? ";expires=" + expires.toGMTString() : "") +
( (path) ? ";path=" + path : "") +
( (domain) ? ";domain=" + domain : "") +
( (secure) ? ";secure" : "");
}
var today = new Date();
var zero_date = new Date(0,0,0);
today.setTime(today.getTime() - zero_date.getTime());

var todays_date = new Date(today.getYear(),today.getMonth(),today.getDate(),0,0,0);
var expires_date = new Date(todays_date.getTime() + (52 * 7 * 86400000)); // 52 weeks

var name = 'cookied';
var value = '52477001';

Set_Cookie(name,value,expires_date);
//--></SCRIPT>


</head>

</html>


Now, if i want the cookie to expire after, say, 15 minutes, what should i edit? is it the 52*7*86400000?

thanks in advance,

d52477001

Roy Sinclair
06-04-2003, 04:33 PM
Yes, the 52*7*86400000 is setting the cookie to expire in one year (which is 52 weeks times 7 days per week times 86400000 milliseconds per day). Fiveteen minutes would be 15*60*1000 or fiveteen minutes times 60 seconds per minute times 1000 milliseconds per second.

d52477001
06-04-2003, 05:57 PM
ah right, it's in milliseconds....

thanks!

d52477001



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum