So for my website I'm trying to store an array in a cookie and call it back whenever. After searching through the first 10 pages of google I'm at a complete loss. Below is a super simplified version of the code.
On the first page I have:
$Info = array( 'Bob', '21');
setcookie("user", $info, time()+3600);
And then on the following page I have the code:
$WOO= $_COOKIE["user"];
echo $WOO[0];
I've tried serializing and unserializing to no avail. It has to be something super simple but I just can not figure it out. Any help is greatly appreciated.
0
Posts
Our first game is now available for free on Google Play: Frontier: Isle of the Seven Gods
Our first game is now available for free on Google Play: Frontier: Isle of the Seven Gods
Your minimal example without serialization should have given you some sort of error (or at least, it gives me an error). Whatever is preventing it from working even when you serialize it might show up there too.
edit: additionally, the default path might be too specific. You may need to set the path parameter to setcookie().
It may help to check your browser's development tools to determine what cookies have been saved.
First Page (works fine, stores cookie):
Second page (can't access cookie):
2) Could you provide the output of var_dump($_COOKIE) in your second script?
That will make your cookie available to any page inside your domain.