Categories


Firefox 22 and Facebook Applications

In the past few weeks there have been a number of articles that have hit the interwebs talking about the impact of Mozilla’s decision to stop Firefox from eating third party cookies.  Here’s one of the many articles, for reference.

Firefox 22 to Stop Eating Third-Party Cookies | Webmonkey | Wired.com.

I just realized that this is going to cause issues for Facebook Applications, simply, Facebook applications will break because they won’t get a user session due to their blocking of the third party cookie.

I wrote another post on how to fix this problem, and it is by no means elegant.  It effectively involves breaking the user out of Facebook temporarily, so their browser will accept a cookie, then taking them back into the application.  You can read the original post here, or simply append the code below to the header of your app.

<!--?php 
$facebookpageurl = "http://www.facebook.com/YOURPAGEURL";
$facebookappid = "YOURFACEBOOKAPPID";

$browser = getBrowserName();
if($browser == "Apple Safari") {
	session_start();
	$page_url = $facebookpageurl . "/app_" . $facebookappid;

	if(isset($_GET['start_session']))
		die(header("Location:".$page_url));
	if(!isset($_GET['sid']))
		die(header("Location:?sid=".session_id()));
	$sid = session_id();
	if(empty($sid) || $_GET['sid'] != $sid):
	?--><script type="text/javascript">// <![CDATA[
			top.window.location="?start_session=true";

// ]]></script><!--?php 
	endif;
}

function getBrowserName() {
	$u_agent = $_SERVER['HTTP_USER_AGENT']; 
	if(preg_match('/MSIE/i',$u_agent) &#038;& !preg_match('/Opera/i',$u_agent)) { 
		$bname = 'Internet Explorer'; 
	} elseif(preg_match('/Firefox/i',$u_agent)) { 
		$bname = 'Mozilla Firefox'; 
	} elseif(preg_match('/Chrome/i',$u_agent)) { 
		$bname = 'Google Chrome'; 
	} elseif(preg_match('/Safari/i',$u_agent)) { 
		$bname = 'Apple Safari'; 
	} elseif(preg_match('/Opera/i',$u_agent)) { 
		$bname = 'Opera'; 
	} elseif(preg_match('/Netscape/i',$u_agent)) { 
		$bname = 'Netscape'; 
	}
	return $bname;
}
?-->

Your Comment