开发者

Change this function to make the cookie expire to 30 seconds

How can I change this function to expire instead of days in 30 seconds?, I have no idea about this.. and its from Telerik

function setCookie(c_name,value,expi开发者_高级运维redays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
} 


You could use the valueOf function:

var numberOfSeconds = 30;
var exdate = new Date(new Date().valueOf() + 1000 * numberOfSeconds);


Instead of .getDate() and .setDate() (which get and set the day-of-the-month), use getSeconds:

exdate = new Date(exdate.setSeconds(exdate.getSeconds()+30));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜