#33939 [Opn->Bgs]: Unsetting $_SESSION variables seems to restart script

From: Date: Sun, 31 Jul 2005 22:39:35 +0000
Subject: #33939 [Opn->Bgs]: Unsetting $_SESSION variables seems to restart script
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-82741@lists.php.net to get a copy of this message
ID: 33939 Updated by: sniper@php.net Reported By: tomator at poczta dot onet dot pl -Status: Open +Status: Bogus Bug Type: Session related Operating System: WinXP pro PHP Version: 5.0.3 New Comment: 1) your example script can't work (missing session_start()) 2) Your PHP version is not the most recent released one. 3) This is most likely user error, sessions work just fine as long as you use them correctly. Previous Comments: ------------------------------------------------------------------------ [2005-07-31 23:37:46] tomator at poczta dot onet dot pl Now I know that server on which my script fails, works with Apache 2.0.54-2 and PHP 4.3.11-4. ------------------------------------------------------------------------ [2005-07-31 22:39:37] tomator at poczta dot onet dot pl Description: ------------ I've made a small application that searches given website, gathers links, follows them and collects informations about file sizes. Becouse it's time consuming, for bigger sites my page is being reloaded few times. All needed data are stored in and restored from $_SESSION. Everything works fine if website is small enough to count it in one step. If not, instead of final summary page I was getting a start page! I found, that it was caused by destroyed session variables. But they were to be destroyed at the end, where I include this file and after the results should have been displayed. See attached code... This is the only place where I use unset. When these lines are commented, I can see a data presentation. But then I can't go back to initial page (becouse of still existing session vars). When unset were not commented, and I put exit() before them, the results were visible. So I think that after unsetting session vars script runs again from begining and looses any informations stored already in output buffer. Well, it seems it is. I put flush() before unsets and made it working almost well. I'm using WinXP Pro, PHP 5.0.3, Apache 2.0.43 (as service), P4 HT It may be Apache related issue as I found it working on another server with PHP 5.0.3 and server software IPL (iPlanet?) and not working on another one with Linux - but don't know if it has an Apache and what version. Reproduce code: --------------- <?php $files=$_SESSION['files']; $total=count($files); $done=$_SESSION['fid']; $sum=0; foreach ($files as $file) { if ($file['size']>0) $sum+=$file['size']; } ?> <TABLE><!--here some result presentation--></TABLE> <?php unset ($_SESSION['files']); unset ($_SESSION['filter']); unset ($_SESSION['presentFiles']); unset ($_SESSION['fid']); unset ($_SESSION['url']); unset ($_SESSION['progress']); ?> Expected result: ---------------- A table should be wisible with results of counting that was done in foreach loop. Actual result: -------------- If unset ($_SESSION['progress']) is enabled, I'm getting initial page, like when entering first time. If unset ($_SESSION['progress']) is disabled, application remembers what should it display, but I'm getting messages about wrong indexes (files, fid) and bad parameter of foreach. If all unsets are disabled, results are fine, but application can't return to it's initial state to take new job. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33939&edit=1

« previous php.bugs (#82741) next »