php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33939 Unsetting $_SESSION variables seems to restart script
Submitted: 2005-07-31 22:39 UTC Modified: 2005-08-01 00:39 UTC
From: tomator at poczta dot onet dot pl Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.0.3 OS: WinXP pro
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tomator at poczta dot onet dot pl
New email:
PHP Version: OS:

 

 [2005-07-31 22:39 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-31 23:37 UTC] 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-08-01 00:39 UTC] sniper@php.net
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.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 13:01:30 2024 UTC