开发者

javascript Cookie with variables?

I'm trying to store the OldURL into the cookie data - bu开发者_Go百科t everytime it puts the expires date and everything? The content of the cookie is expiration date and URL, and the real expiration date is delete on browser close?

document.cookie = "MyTracker="+oldURL+";expires=1 Jan 2050 23:59:59 UTC; path=/";


Hmz, tested the definition you're using. I can safely say it's either the way you're testing the cookie or the value of oldURL.


You can use the function below:

function setCookie(c_name,value,exdays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); document.cookie=c_name + "=" + c_value; }

and check this out: http://www.w3schools.com/JS/js_cookies.asp

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜