Reputation: 21
When I make a JavaScript cookie like this:
document.cookie = "hh=234,23423,324";
And I read it from PHP like this:
echo ($_COOKIE['hh']);
It is only returning the value: 234 and not: 234,23423,324
In google chrome resources tab the entire value is shown as '234,23423,324'.
Any information is helpful [1]: https://i.sstatic.net/5IpXg.png
Upvotes: 2
Views: 105
Reputation: 5907
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.
Try this in JavaScript: document.cookie = 'hh="234,23423,324"';
Read more in Mozilla's cookie documentation.
Upvotes: 3