RE: [PHP] SESSIONS HELP

From: Date: Thu, 08 May 2003 06:28:08 +0000
Subject: RE: [PHP] SESSIONS HELP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146786@lists.php.net to get a copy of this message
At 02:09 08.05.2003, Jennifer Goodie said: --------------------[snip]-------------------- >Did you read the manual page on session_write_close at all? By default the >session closes on every single page when the script terminates, that is what >makes it accessible by the next page. The session is suppose to close. You >need to read about sessions before you try to use them, or you are going to >run into problems. > >> -----Original Message----- >> From: Dale [mailto:DaleHersh@hotmail.com] >> Sent: Wednesday, May 07, 2003 4:59 PM >> To: php-general@lists.php.net >> Subject: [PHP] SESSIONS HELP >> >> >> Jennifer, >> You do have a valid point in regards to saving and closing the >> session. BUT >> if I close the session, then what will happen when I try to access the >> session variables on the following page. --------------------[snip]-------------------- Jennifer, there might be a valid point in using session_write_close() just before sending a header('Location: foo.php');. After this header transmission the PHP script will actually continue to run, and its session data will be flushed to persistent storage only after the script eventually terminates. If this script is doing some lengthy operation it is quite possible that the client had already reacted to the redirect and fetched the relevant page, utilizing outdated session data. This will usually work without such problems: header('Location: somewhere-else.php?' . SID); exit; This might get you into trouble: header('Location: somewhere-else.php?' . SID); do_some_lengthy_operation(); // ... /* finally */ exit; so you might consider using session_write_close(); header('Location: somewhere-else.php?' . SID); do_some_lengthy_operation(); // ... /* finally */ exit; -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/

« previous php.general (#146786) next »