How do I access user_id:
This is the print_r of my cookie:
Array
(
[PHPSESSID] => gv0hsh6uel9kiuprdoc0uqboq4
[oauth_token] => 40533855-FNM77JeuJIPdKclYyaT2Fi9jZRu2NGAHh5FeveNk
[oauth_token_secret] => C6GDTEu60rGa4aDbqjncm6yfUf9Xc9520AuX9GXag
[SocialAuth] => a:2:{s:4:"type";s:8:"facebook";s:7:"user_id";s:2:"22";}
[__utma] => 157144508.1187834205.1333154906.1333154906.1333154906.1
[__utmb] => 157144508.35.10.1333154906
[__utmc] => 157144508
[__utmz] => 157144508.1333154906.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
)
My user ID in this is at the end of the SocialAuth line… “22”. But I cant seem to access it.
$user = $_COOKIE["SocialAuth"]["user_id"];
Returns “a”.
Am I doing this right?
Thanks in advance.
You have a serialized array in
$_COOKIE['SocialAuth']. Take a look at the manual pages for serialize and unserialize.Use unserialize like this to access the user id:
Or prior to PHP 5.4: