I am using a combination of Javascript and PHP Facebook sdk to integrate the log in to my website (hosted on localhost).
The code after Facebook initialization and getting the access token:
if(fbidExists($profile['id']) == true)
{
$query = "SELECT userid AS id, username FROM users WHERE fbid = ". $profile['id'] ;
$login = mysqli_fetch_assoc(mysqli_query($GLOBALS['connection'], $query));
$_SESSION['id'] = $login['id'];
$_SESSION['username'] = $login['username'];
header("Location: http:\\\\localhost\website\\");
exit();
}
Problem:
After redirect there are no session variables whenever I use $login['username']
, otherwise the session variables are transferring.
If I change the SQL query and replace username
by any other column there is no problem and I can see the session variables after redirect. For example :
$query = "SELECT userid AS id, email FROM users WHERE fbid = ". $profile['id'] ; $_SESSION['username'] = $profile['email']
creates no problem
The $_SESSION['username']
variable can be easily set through other files and creates no problem (when i use it with my own log in)
username
in MySQL is of varchar
type and I am using session_start()
on every page and exit()
after header.