Hello, I'm working on persistent logins, and I'm having trouble with serialize and unserialize. Right now, I'm just doing a test and I'm trying to set a cookie named 'login' as such:
setcookie("login", serialize(array("un" => $username)), time() + 31104000);
Which, right now, just has a username variable.
That results in the following serialized data if I print_r the $_COOKIE['login'] variable:
a:1:{s:2:\"un\";s:9:\"username\";}
However, if I try something like:
print_r(unserialize($_COOKIE['login']))
or
$login = unserialize($_COOKIE['login'));
print_r($login);
I get nothing. Nothing is printed at all, and I can't access my data. However, if I just do print_r($_COOKIE['login']) I can see the serialized data. For some reason, the unserialize function is returning empty. Any ideas?!?