ID: 14636 Comment by: lucashynar at hotmail dot com Reported By: kannan at tmsassociates dot com Status: Bogus Bug Type: Session related Operating System: windows 2000 professional PHP Version: 4.0.6 New Comment:
I am sure anybody that is trying to use IIS and PHP is throughly annoyed with the session_start() bug that recreates a new session every time it is accessed. The problem is the session_id isn't passed before the session_start() so it creates a new session. So a simple sollution is: $id = 473483478383834; session_id($id); session_start(); Another way that is a bit more dynamic using a Cookie to hold the session_id: if (isset($SessID)){ session_id($SessID); } session_start(); header("Cache-control: private"); // IE 6 Fix. setcookie("SessID", session_id(), time() + 3600); There are probably much better ways of doing this but for use with my offline Win/IIS setup it seems to be fine. Previous Comments: ------------------------------------------------------------------------ [2004-08-12 10:27:37] venky at netkode dot com Hi, As i said earlier i have login page which registers session variables and go to the login area where check.php will check for the session variables. Here i compare old session id stored in session variable with session_id(). but here initially stored sessionid and session_id() were not equal. It means browser is generating new id after redirected. Could anyone help me in work around for this. I am desperately waiting for help over this. ------------------------------------------------------------------------ [2004-08-10 17:49:42] mhdskr at yahoo dot com I faced exactly the same problem : (USING W2K-IIS5/PHP4.3.7) I take the login username and password and store it in the session and then redirect to another page .. The first time I reach there the session is not set. I hit browser back and re enter the login information it works fine The first login page contains html only - no php I start the session in the second page that checks the login and redirect to the third page MY SOLUTION - it worked for me in this way! : I added the following to the first (html-only) page : <?php session_start(); ?> Isn't it strange ?!? ------------------------------------------------------------------------ [2004-08-03 07:38:51] venky at netkode dot com Hi, I am facing the similar problems with Sessions. I register session variables in the Login page and redirect through header to user area and have one checklogin file which will check the sessionid and some other session values. But here I am not able to get the values. This issue is not occuring very often but out of 500 attempts one or two complaints are coming up. Most of the cases are with I.E 6.0. Any work around will be of great help. ------------------------------------------------------------------------ [2004-07-16 06:30:23] anonymous at anonymous dot com Yes I have recently seen this phenomenon. Note that I am purposely NOT saving session data in cookies. session_start(); $_SESSION["foo"] = "bar"; header( "Location:foobar.php" ); On the remote Unix server running Apache I upload this to, it works fine. The session data is passed to foobar.php. However on my local Windows machine, the session data is lost. I end up having to pass session data in the header myself. header( "Location:foobar.php?" . Session_Name() . "=" . Session_ID() ); It works but I'd rather not resort to that. ------------------------------------------------------------------------ [2004-05-23 21:02:41] lorenzob at interia dot pl I'm working on PHP 4.2.3 with Apache 1.3.9 and I've got the problem mentioned above. After logging in I do the simple session_start() $_SESSION['user'] = $_POST['login'] and as for that everythings fine. But when changing from test.php, where above code is stored, into another page klient.php during the same session the variable appears to be empty! In short, although the variable is being registered fine it's not visible in other scripts, what is an obvious denial of an idea of session variables. Can anyone help? I've been fighting this one for over three days in many ways but nothing seems to have an effect. test.php: session_start(); header("Cache-control: private"); ob_end_flush(); session_register("log"); session_register("pas"); $log = $_POST["login"]; $pas = $_POST["pass"]; klient.php: session_start(); header("Cache-control: private"); ob_end_flush(); $im = $log; $naz = $pas; echo "->".$im; Big thanks in advance ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/14636 -- Edit this bug report at http://bugs.php.net/?id=14636&edit=1