I was stuck up with similar issue, here is the solution that may help you.
$facebook = new Facebook(array(
'appId' => 'xxxx',
'secret' => 'xxxxx',
"redirect_uri" => "set the uri to point to the same page"
));
$user = $facebook->getUser();
if($user)
{
//your task
} else {
header('location:'. $facebook->getLoginUrl());
}
$user = $facebook->getUser();
if($user)
{
//your task
} else {
header('location:'. $facebook->getLoginUrl());
}