我的cookie已设置但php无法读取它

I've been trying to make a cookie autologin, but although the cookie is set, php can't read it. I know it is set because I can see it with Cookie Monster, I don't know what's wrong... Need help! It's driving me crazy!

The code to set the cookie (I do it before any HTML tag)

setcookie("autologin", $_SESSION['user'], time()+5184000, "/");

the code to retrieve it:

if (!isset($_SESSION['user']) && isset($_COOKIE['autologin'])) {
     $_SESSION['user']=$_COOKIE['autologin'];
}

UPDATE: I don't use the code above in the same script. I do login, close the browser, reopen it and try to get the cookie, cookie is in Cookie Monster but php can't see it.

FIX: My problem was I was trying to save a serialized object, $_SESSION['user'], in the cookie, it has been fixed with that:

setcookie("autologin", base64_encode($_SESSION['user']), time()+5184000, "/");

and retrieving with:

if (!isset($_SESSION['user']) && isset($_COOKIE['autologin'])) {
         $_SESSION['user']=base64_decode($_COOKIE['autologin']);
}

My problem was I was trying to save a serialized object, $_SESSION['user'], in the cookie, it has been fixed with that:

setcookie("autologin", base64_encode($_SESSION['user']), time()+5184000, "/");

and retrieving with:

if (!isset($_SESSION['user']) && isset($_COOKIE['autologin'])) {
         $_SESSION['user']=base64_decode($_COOKIE['autologin']);
}

This cookie will available on next page loading. In this page you can define it yourself.