I am trying to implement facebook login.
Upon logging in I use the user’s email(I get it by the facebook graph) to create a session.
The code for logging in is this(in short)…it takes account 2 scenarios…logging in with Fb and with a traditional form.
//check if user logs in via facebook
if(isset($_GET['access_token']))
{
$user_profile = $fb->get('/me?fields=email',$_GET['access_token']);
$user_data=$user_profile->getDecodedBody();
$_SESSION['regular_user']=$user_data['email'];//the users's mail is got from facebook graph
}
//the code below runs when there is no session(it is destroyed on logout)
if(!isset($_SESSION['regular_user'])){
header("Location: ../Frontend/login.php");
}
The problem comes on logging out at which point a destroy the session and the user hits the browser back button.
At which point it goes to the page where its URL contains the Fb access token…and according to the way the code is structured above a login takes place…nonetheless this must not happen cause the user has just logout.
How I could reorganize the code so as to avoid this…adding the scenario of creating a session with Fb login complicates things.