Refresh cookies for a Facebook site?

I am using the Facebook Connect API to login to a website created using PHP. There is no easy way to determine if a user is registered.

$fb = new Facebook($api, $secret);
$fb->get_loggedin_user();  

The above function always returns the user ID, as soon as the user is authenticated with the site, even if they log out of Facebook, he still returns his user ID.
I’ve been working on this for a while, and looking back, I think the reason is that it does this because when a user authenticates to the site, the JavaScript JavaScript API stores cookies that are used to store session information. <w> However, if the user signs up from a regular Facebook session, the cookie still returns values, even if the session is no longer valid.
My question is: how do I update cookies so that they don't give me meaning when the session is no longer valid?

+3
source share
1 answer

It can be a little tricky. Basically, Facebook stores a bunch of cookies in a user browser, which are referred to by your application identifier (i.e. 12345_fb_sig=, etc.). These cookies are used to inform your FB Connect application that the user is logged in to Facebook and to transmit the facebook session ID. But if the user goes to another place and logs out, these cookies are not cleared, and as far as your site is connected, the user is still registered. If the user returns later and you try to call the API using this session key, it does not work.

cookie PHP FB API, $facebook->api_client->clear_cookie_state(), . - API , , - .

, - FB Javascript, FB Connect. FB.init(), FB Connect, , :

FB.init("<YOUR-API-KEY>", "<YOUR-CROSS-DOMAIN-CHANNEL-URL>", {"reloadIfSessionStateChanged":true}); 

, , , , . .

+3

Source: https://habr.com/ru/post/1727066/


All Articles