note 35174 added to ref.session

From: Date: Fri, 22 Aug 2003 08:58:02 +0000
Subject: note 35174 added to ref.session
Groups: php.notes 
Request: Send a blank email to php-notes+get-54853@lists.php.net to get a copy of this message
I have experenced some odd problems when using sessions and since I seem to have solved it I'd just like to share the problem and solution since maybe someone else experiences the same. The problem was that when the user logged in through a form the script was supposed to set some variables to inform other scripts that the user was authorized to view other pages. The session variables would be set but after beeing redirected to the next page they were gone. Going back to the login page and loggin in again would make it work. The problem seems to be related to Apache not beeing able to determine is full servername. The problem appeared when accessing the server through the hostname (eg. server.foo.bar) but everything worked fine when accessing it by its IP-adress. Defining the correct ServerName in httpd.conf seems to have solved the problem. However, the problem reappears if the user browses to the login page by using the hostname and the script redirects using the servers IP-adress. (ie, user surfs to server.foo.bar/login.php which authenticates and redirects to x.y.z.w/nextpage.php). So, in short, make sure the server knows its own servername and try not to redirect between IP-adress and hostname. I have no idea why this happens so it may be fixed in more recent versions. ---- Manual Page -- http://www.php.net/manual/en/ref.session.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35174 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35174&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35174&report=yes

« previous php.notes (#54853) next »