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));
精彩评论