I am developing a website which has support for members to login
I use mysql for a user-database.
When a user wants to log in, he enters name and password and clicks "login" button, which takes him to login.php
In login.php:
I first do session_start();
Then I check the database to see if the user/password combination exists. if it exists, I set $user_allowed to 1, else I set $user_allowed to 0.
This variable and the username, and a userlevel, taken from the database, is registered with the session using
session_register('user_allowed', 'user_level','user_name');
Then the user is redirected to index.htm (using header ("Location :"index.php").
In index.php, I first do session_start();
Then I check if $user_allowed is 1 and if it is, some data is displayed, and if it is not, the user is redirected back to the login-page.
Should work, right? Well, sometimes it does, sometimes it does not. The problem is that in index.php, after the session_start();, the $user_allowed variable is NOT registered and also the user_name and user_level variables are not registered anymore!
What is wrong? (php version is 4.1.2)
I checked the session_id()'s, they are the same, during a session, so this is not the problem.
Help.