RE: [PHP] Session-problems in linux

From: Date: Mon, 25 Jun 2001 16:52:55 +0000
Subject: RE: [PHP] Session-problems in linux
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-55158@lists.php.net to get a copy of this message
I had EXACTLY the same problem about a month a go, but using IIS on Win2k. The session file contains only ":foo|", so it's just the same. There are a couple of things to check: 1. Make sure the browser is receiving the cookie. 2. Make sure the browser is returning the cookie (should appear using phpinfo()). 3. Make sure a file named with the value of the PHPSESSID cookie exists on the server. I solved the problem by turning off session.auto_start on php.ini and then using the following code to start the session: function MySetCookie ($CkyName, $CkyVal, $exp, $pth, $Domain) { $exp = strftime("%A, %d-%b-%Y %H:%M:%S", $exp); $cookiestr = sprintf ("%s=%s; domain=%s; path=%s; expires=%s", $CkyName, $CkyVal, $Domain, $pth, $exp); $mycky = (isset($mycky) ? "$mycky\n" : "")."Set-Cookie: $cookiestr"; header($mycky); } session_start(); MySetCookie("PHPSESSID",session_id(),0, "/", ""); Make sure this code appears before any header is sent, that is, before any session, cookie or header instruction. If you do all this and still have the same problem, try registering each session variable that you are going to use just after starting the session. I don't know why, but sometimes PHP requires all session variables registered before you can access their values. Hope it's been of some help. Cheers, Diego. -----Original Message----- From: Tjelvar Eriksson [mailto:tjemalaga@hotmail.com] Sent: Monday, 25 June, 2001 7:09 PM To: php-general@lists.php.net Subject: [PHP] Session-problems in linux Hi everyone, I can't get the sessions working in linux. I changed: /usr/local/lib/php.ini session.auto_start = 1 so when the browser go to the page, a cookie is recieved. In the /tmp-dir a file is created and everything looks great. However, when I register a variable and set it to a value, only the name, not the value is stored. I've tried to store strings, arrays, integers but no luck. I do: session_register("foo"); $foo="Great day"; and the file will only contain ":foo|" with no accompanying value. I'm really stuck here, and everything works fine in windows but not in RH7.1. I would be very greatful for any hints here. /t eriksson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#55158) next »