views:

2329

answers:

3

What is the best way to keep the user logged in when something like "third-party" cookies are disabled. I currently have a Facebook connect app (in only PHP) that works great when I have that checked in Firefox, but redirects to my login page when it's unchecked. Even Facebook's own sample application (therunaround) has the same problem with this unchecked so I'm wondering if there's no way around the issue.

Edit:

@codege3k

Tried a bunch of p3p headers. No dice so far. I've got a login page that redirects to my index when the user "connects" ... the first load, I'm able to get the user id from get_loggedin_user() but when I refresh, that function returns null. The cookies exist, and when I go back to the login page and click connect again it doesn't prompt me for a login, so I know it's partly working. With "third-party cookies" turned on in Firefox, it works like a charm.

Edit:

What is the best way to handle facebook connect in the context of a user login then if third party cookies is not widely supported? Should I just use the initial login that works and set a local cookie for my own site and use that instead of checking the facebook status every time?

+2  A: 

I had a similar issue with 3rd party cookies. Check this question and see if it resolves

It can be solved by adding p3p headers.

Shoban
+2  A: 

Ok, promoting the session seems to work.

$fbUserId = self::$facebook->get_loggedin_user();
if ($fbUserId)
{
     self::$facebook->promote_session();
     return $fbUserId;
}

Edit:

So this gets the session on every request, but essentially, third party cookies must be enabled for Facebook Connect to work as expected. From their docs:

The user's browser must be set to accept 3rd Party Cookies in order for it to stay connected between clicks.

Source: http://wiki.developers.facebook.com/index.php/Logging_In_And_Connecting

Typeoneerror
A: 

So does P3P work to fix this for browsers that don't accept 3rd party cookies? I commented on a FB bug at http://bugs.developers.facebook.com/show_bug.cgi?id=5009.

I haven't seen much difference with the P3P headers. In firefox with those "third party cookies" unselected, it doesn't work, no matter what. You can get the initial value from facebook and set a local cookie yourself if needed.
Typeoneerror