At first time when i login to facebook in my browser. i called function getuser for checking purpose but i cant get it it returns zero only. it happened only when i open the browser at first time.
$facebook = new Facebook(array(
'appId' => 'xxxxx',
'secret' => 'xxxxxxx',
'cookie' => true
));
$here = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$next = preg_replace('~#.*$~s', '', $here);
$next = preg_replace('~\?.*$~s', '', $next);
$next = preg_replace('~/[^/]*$~s', '/login.php', $next);
$params=array(
'scope' => 'publish_stream,user_birthday,read_stream,read_friendlists,user_about_me,email,user_checkins,friends_checkins,publish_checkins,publish_actions',
'redirect_uri' => $next
);
$loginUrl = $facebook->getLoginUrl($params);
The SDK stores the facebook user ID and access token in a session, so getUser won't return 0 after auth unless you clear your cookies or re-open your browser like you've done.
You can also call destroySession()
to remove the cookies in the SDK.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.