Home  >  Article  >  Web Front-end  >  IE cannot set Cookie_javascript tips under short domain name

IE cannot set Cookie_javascript tips under short domain name

WBOY
WBOYOriginal
2016-05-16 18:19:171255browse

After some simple troubleshooting, I found the problem and the cookie setting failed.

But as for why it failed, I searched this issue for a long time, and finally someone mentioned on StackOverflow that IE cannot set cookies for short domain names starting from 5.0.

How long does it take for problems to occur? After testing, it was found that a total of 5 characters including a period, including 5 characters, cannot be used to set Cookie through Javascript. However, there is a premise here, that is, it will fail only when you explicitly specify the domain parameter when setting Cookie. That is to say, if you write like this:

View source code print help document.cookie="key=value;domain=ab.cn";

Cookie setting will fail if the domain parameter is removed , write directly like this:

View source code print help document.cookie="key=value";

This problem will not occur, even if the current domain is still ab.cn.

This articlehttp://support.microsoft.com/kb/310676/en-us/ mentioned a similar problem, but it seems to be different from this situation. You can also refer to it.

Because the cookie setting failed, our traffic monitoring system considered each visit to be a new visit, and the natural bounce rate was extremely high. However, GA seems to have failed to send data if the cookie setting failed.

Firefox and Chrome have no such problem.

Mark this, I hope it will be helpful to people who encounter similar problems.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn