When I make a JavaScript cookie like this:
当我像这样制作一个JavaScript cookie:
document.cookie = "hh=234,23423,324";
And I read it from PHP like this:
我从PHP中读到这样的:
echo ($_COOKIE['hh']);
It is only returning the value: 234 and not: 234,23423,324
它只返回值:234而不是:234,23423,324
In google chrome resources tab the entire value is shown as '234,23423,324'.
在Google Chrome资源标签中,整个值显示为“234,23423,324”。
Any information is helpful [1]: http://i.stack.imgur.com/5IpXg.png
任何信息都有帮助[1]:http://i.stack.imgur.com/5IpXg.png
1 个解决方案
#1
You need to store your cookie as a string and not as a number. Otherwise your cookie may be interpreted as number, stopping parsing at first non-digit character.
您需要将cookie存储为字符串而不是数字。否则,您的cookie可能会被解释为数字,停止解析第一个非数字字符。
Try this in JavaScript: document.cookie = 'hh="234,23423,324"';
在JavaScript中试试这个:document.cookie ='hh =“234,23423,324”';
Read more in Mozilla's cookie documentation.
阅读Mozilla的cookie文档中的更多内容。
#1
You need to store your cookie as a string and not as a number. Otherwise your cookie may be interpreted as number, stopping parsing at first non-digit character.
您需要将cookie存储为字符串而不是数字。否则,您的cookie可能会被解释为数字,停止解析第一个非数字字符。
Try this in JavaScript: document.cookie = 'hh="234,23423,324"';
在JavaScript中试试这个:document.cookie ='hh =“234,23423,324”';
Read more in Mozilla's cookie documentation.
阅读Mozilla的cookie文档中的更多内容。