[英]Read PHP cookie from JavaScript cookie
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
You need to store your cookie as a string and not as a number. 您需要将Cookie存储为字符串而不是数字。 Otherwise your cookie may be interpreted as number, stopping parsing at first non-digit character.
否则,您的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文档中了解更多信息 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.