I am using the PHP SDK getLoginUrl() function which works perfectly to log the user in. Once the user is redirected back to my page, the URL can come in two forms, see in the following link subsection 3: http://developers.facebook.com/docs/authentication/server-side/
Part of the return URL is a ?state= value. This value is supposed to be used to prevent Cross Site Request Forgery: http://developers.facebook.com/docs/reference/dialogs/oauth/
Though, using the getLoginUrl() method I can never set a state value as it is not one of the parameters: http://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/
So how can I utilize the state-value to log a user into facebook and prevent CSRF?
$loginUrl = $facebook->getLoginUrl(array('scope' => 'email', 'redirect_uri' => FACEBOOK_REDIRECT_URL)); $_SESSION['state'] = $_SESSION['fb_'.FACEBOOK_APP_ID.'_state'];. Then when authenticating after the redirect back to your site:if($_SESSION['state'] == $_REQUEST['state']) { //not CSRF }- uguMark