note 51691 added to ref.session

From: Date: Thu, 07 Apr 2005 17:34:11 +0000
Subject: note 51691 added to ref.session
Groups: php.notes 
Request: Send a blank email to php-notes+get-87667@lists.php.net to get a copy of this message
I am using PHP 5 and I ran into a problem using $_SESSION and session_start() because they do not store values. I have the register_globals option set to Off and the session.auto_start set to 0. I am running apache 2.0 on my computer as a test server through localhost. I added a simple example to show the problem. Maybe someone has useful information on how to solve it. (it has also caused me trouble when I am trying to use -User Authentication Applications-). If some one owns the book PHP and MySQL web development by Laura Thompson and Luke Welling, my trouble resides on chapters 22, 26 and 28 when trying to log into the CMS because it does not store the value (username and password) and redirects me to the proper page (writers.php or publish.php) and stays in login.php. Example: page1.php------------------------------------------------------- // This first page is suppoused to store "Hello world!" as a value in the $_SESSION['sess_var'] so it can pass it to page2.php <?php session_start(); $_SESSION['sess_var'] = "Hello world!"; echo 'The content of $_SESSION[\'sess_var\'] is ' .$_SESSION['sess_var'].'<br />'; ?> <a href="page2.php">Next page</a> page2.php------------------------------------------------------- // Somehow it does not display "Hello World!" <?php session_start(); echo 'The content of $_SESSION[\'sess_var\'] is ' .$_SESSION['sess_var'].'<br />'; unset($_SESSION['sess_var']); ?> <a href="page3.php">Next page</a> page3.php------------------------------------------------------- <?php session_start(); echo 'The content of $_SESSION[\'sess_var\'] is ' .$_SESSION['sess_var'].'<br />'; session_destroy(); ?> ---- Manual Page -- http://www.php.net/manual/en/ref.session.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51691 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51691&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51691&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51691&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51691&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51691&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51691&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87667) next »