can't get session vars

From: Date: Sat, 22 Jul 2000 01:55:45 +0000
Subject: can't get session vars
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-7653@lists.php.net to get a copy of this message
I'm getting very angry and frustrated and wasting a lot of time trying to get sessions working with no success. I'm on Solaris 2.7, using apache_1.3.12 and php-4.0.1pl2. In my php.ini file both register_globals and track_vars are On, and the output of phpinfo() says they're both On. When I configured php I specified --enable-trans-sid. (For some reason the documentation at php.net says to set gpc_globals in the php.ini file but as far as I can tell it's register_globals I need to set. I did a grep on all of the source files and couldn't find gpc_globals.) Here are the two files; output0.php has a link to test3.php; I can't see the registered variable in test3.php. In output0.php when I move the mouse over the link to test3.php I can see the ?PHPSESSID=a6d95c(lots more chars) in the status at the bottom of the browser window appended on the url. The session_is_registered() is returning true in output0.php. The one thing that looks puzzling is in the output of phpinfo(); under Apache Environment it has HTTP_COOKIE as PHPSESSID=a6d95c(lots more chars) Then under HTTP Headers Information, HTTP Request Headers, it has HTTP Request and there is the same string, and likewise for Cookie under HTTP Request Headers. But under HTTP Response Headers there is Set-Cookie and it has PHPSESSID=ccc99b(lots more chars) Under PHP Variables both HTTP_GET_VARS and HTTP_COOKIE_VARS have a6d96c... for PHPSESSID. In my /tmp directory where it's storing the session data, there are two sess_ files with the corresponding numbers, but the one that starts with sess_a6d995c has pr_email|s:5:"a@b@c"; while the one that starts with sess_ccc99b is empty (0 bytes). I added the following line to both files in the <body> part and it's giving a different number in output0.php and test3.php: echo("Session id is " . session_id() . "<p>"); What's going on?! ====> start of output0.php <===== <script language="php"> session_start(); $pr_email = "a@b@c"; if (! session_register("pr_email")) $err_msg = "Could not register $pr_email."; </script> <html> <body> <script language="php"> if (isset($errmsg)) { err_msg($errmsg); exit; } </script> <script language="php"> echo("$pr_email logged in.<br>"); if (session_is_registered("pr_email")) echo("pr_email registered.<br>"); </script> <a href="test3.php">Continue</a> </body> ====> end of output0.php <===== ====> start of test3.php <===== <script language="php"> session_start(); /* session_register("pr_email"); */ </script> <html> <body> <script language="php"> if (! isset($pr_email)) echo("<p>pr_email isn't set.<p>"); else echo("<p>Your login is $pr_email<p>"); phpinfo(); </script> </body> ====> end of test3.php <=====

« previous php.general (#7653) next »