Posts

Showing posts with the label session-variables

$_SESSION variable is null before I set it to null

Image
Clash Royale CLAN TAG #URR8PPP $_SESSION variable is null before I set it to null I have encountered a weird problem in my php code for a website I'm building: php I use the superglobal $_SESSION['recent'] for creating alerts on my webpages. For example if a user tries to sign in, but gives a wrong password, the sign-in form will send its data to a file login.php which checks if all the data is correct. If the data is correct, it will set $_SESSION['recent'] = 'login_succes' (and a few other things so the user is signed in), else it will set $_SESSION['recent'] = 'login_fail' . Next it will return to the homepage with header('location: http://www.example.com/') . $_SESSION['recent'] login.php $_SESSION['recent'] = 'login_succes' $_SESSION['recent'] = 'login_fail' header('location: http://www.example.com/') In this homepage, there is a chunk of php code with a switch statement which...