make sure you have an if condition to check user status
$user=$facebook->getUser(); if($user) //someactions else { // redirect the user to login and authorize your application, if necessary header('Location:'.$facebook->getLoginURL()); }
Please check the function case. Maybe I'm wrong.
source share