Hi all,

I am using the PHP Facebook SDK to login users. A login button validates the user and returns to a callback 'fb-callback.php'. On this page, I dump the returned data into a mySQL table, start a Session, and redirect to the homepage.

As a test, I stopped the redirect and dumped the session data, and everything looks okay. However, when I dump the session data on any other page, the session doesn't seem to have any data!

Am I supposed to pass it between pages? My understanding was that Session was superglobal, so wht is it not passing between my pages?

To load the session data, I simply use:

    //Load Session
    $user = $response->getGraphUser();
    $_SESSION = $user;

I also start a new session on each page.

Can someone help?

Member Avatar for diafol

Ensure that you have session_start(); at the top of every page.

Yeah I do.

The issue was I needed to store the data under a session array, not into the session itself. When I changed:

$_SESSION = $user;
to
$_SESSION['user'] = $user;

The problem resolved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.