why does this cookie set in PHP keep returning null?
I am trying to set some cookie variables token variables received from twitter and am realizing that I keep getting a null variable for objects that are clearly not null...even for explicitly defined strings. Here is the specific code section I am working with though
var_dump($token->oauth_token);
var_dump($token->oauth_token_secret); // these are not null
// Attempt to save to cookies
setcookie('oauth_token', $token->oauth_token);
setcookie('oauth_token_secret', $token->oauth_token_secret);
var_dump($_COOKIE['oauth_token']); //these cookie variables are null...holds true开发者_Go百科 even for //simple strings...not just the complex twitter objects im working with...happens on chrome //and IE
All help is appreciated!
See http://www.php.net/setcookie (emphasis mine):
Once the cookies have been set, they can be accessed on the next page load with the $_COOKIE or $HTTP_COOKIE_VARS arrays.
精彩评论