I think the things happening in my script are very strange. I've been searching the whole internet twice and couldn't find an answer yet. Maybe someone can help me.
So I got:
logon.php - things are still ok
This file basically just creates a form for a user to logon. This form posts a userid and password to access.php.
access.php - things are still ok
This file retrieves the userid and password. It checks the database for user existence and does a password check. If access is granted I create a session and forward the user to home.php. So this file looks something like:
session_start();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
.. some access checks ..
if ($access) {
$_SESSION["userid"] = $userid;
header("Location: home.php");
}
home.php - things are still ok
This file checks the session for userid, retrieves the user rights from the database and gives a welcome msg. And I create a menu to click to some interesting things. The check for a session happens like this:
session_start();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$userid = $_SESSION["userid"];
if($userid=="") {
header("Location: logon.php");
}
interesting.php - things are still ok
This file uses the exact same check for a session and does the same basic things as home.php. The only thing that changes is that instead of the welcome message a form is given to the user to select the exact interesting the user wants to see, so a form like this:
<form method=post action=interesting.php>
<input type=hidden name=iwantmyscriptto value=showsomething>
<select name=interestingid>
<option value=1>Thing 1</option>
</select>
<input type=submit>
</form>
interesting.php - things go completely wrong !!!
Again the exact same check (it's the same file) for a session is performed but now evaluates false and so the user is forwarded to the logon.php and doesn't get the interesting thingie.
So it looks like the session gets lost while posting the form. Does anyone have an idea what is happening here??
Oh, btw .. already a thanks to everybody thinking about the problem.