Return to Snippet

Revision: 14105
at May 19, 2009 09:45 by ping_ch


Initial Code
function _validateFBConnectCookie(){
	$params = array();
	$apiKey = Configure::read('Settings.fb_api_key');
	
	foreach($_COOKIE as $key=>$value){
		
		if( strpos($key, $apiKey.'_') === 0 ){
			
			$paramName = substr($key, strlen($apiKey)+1);
			
			$params[$paramName] = $value;
		}
	}
	ksort($params);
	$secret = Configure::read('Settings.fb_secret');
	$str = '';
	foreach($params as $key=>$value){
		$str .= $key.'='.$value;
	}
	
	$calculatedSig = md5($str.$secret  );
	
	if(!empty($_COOKIE[$apiKey] ) && $_COOKIE[$apiKey] === $calculatedSig){
		return true;
	}
	return false;
}

Initial URL
validate_facebook_connect_cookie

Initial Description
Use this function to validate cookies set by Facebook Connect JS API

Initial Title
Validate Facebook Connect Cookie

Initial Tags
validation, facebook

Initial Language
PHP