On my registration script i have:
// Save registration information into the database
// Set sessions
$_SESSION['var1'] = 'somevalue';
$_SESSION['var2'] = 'anothervalue';
header('Location: /somewhere');
exit();
Then on my login script i have:
// Check if user provided correct login credentials
if (correct) {
$_SESSION['var1'] = 'somevalue';
$_SESSION['var2'] = 'anothervalue';
}
header('Location: /somewhere');
exit();
What happened is that the session variables were lost after the header redirect in the registration script but they were preserved after the redirect in the login script.
I've checked session_id()
at both pages and they have the same value, included session_start()
at the top of every page and basically tried the solutions to this common problem found on Stackoverflow but somehow nothing seemed to work.
I'm beginning to wonder if it is something to do with my server configuration instead of my code.