开发者

Cookie not set if Firefox 5

开发者 https://www.devze.com 2023-03-22 02:41 出处:网络
I\'ve just discovered that a script that I have to set a cookie does not work in Firefox 5. It does work in Chrome, IE8 and FF4.

I've just discovered that a script that I have to set a cookie does not work in Firefox 5. It does work in Chrome, IE8 and FF4.

The page is on a sub-domain (foo.site.com)

The argument name is a string such as 'view123' and the val is a string that is either 'count' or 'percent'.

The cookie is supposed to expire at the end of the session hence no expiration date.

Below is my script:

function rtSetCookie(name, val){
    document.cookie = name + '=' + escape(val) +开发者_运维问答 
    ';expires="";path="/";';
 }

As I said it works fine in the other browsers not FF5 any ideas why?


It looks like path is breaking when it has " ".

See this http://jsfiddle.net/fukhj/ Removing " works. Make sure you refresh the page twice because the second time reads the cookies.

0

精彩评论

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