I am trying to perform a basic login to my web site, but am having difficulty in gaining access to session variables.
I have a login HTML file which calls an authentication script (authenticate.php). This script checks the login and password against a mySQL database. If successful it extracts some basic details about the user and then stores them in some session variables.
At the end of the script, I use a Header function to move to another page (home.php) which displays the home screen of the authenticated user.
The home.php file checks to see if valid session variables have been set-up and if not returns to the login page. This prevents people typing in the URL of the home page and getting straight in without logging in.
So, pretty straight forward.
Trouble is, the session variables don't seem to get stored before the home.php file is displayed thus making the session variables inaccessible when the home.php script starts to get processed.
If I press the back key on my browser and resubmit the login form, then everything works as planned - presumably because the session variables have since been saved.
Any ideas how to get round this? What do other people do?
Alistair