php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24728 iterating over _SESSION will stuff up session saving
Submitted: 2003-07-20 11:09 UTC Modified: 2003-07-20 11:15 UTC
From: dzlist at zverina dot co dot uk Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.2.2 OS: linux
Private report: No CVE-ID: None
 [2003-07-20 11:09 UTC] dzlist at zverina dot co dot uk
Description:
------------
Using up to date version from RedHat 8.0, 4.2.2

Calling the function below will stuff up saving of _ALL_ session data:


Reproduce code:
---------------
function import_session_variables ($prefix)
{
    global $_SESSION;
    $tab = $_SESSION;

    reset($tab);
    while (!is_null($key = key($tab) ) ) {
        $var = $prefix.$key;
        global $$var;
        $$var = $_SESSION[$key];
        next($tab);
    }
    // if you uncomment the next line sessions will save
    // hence i have a work around
    // it'd be nice to have it fixed properly though
    // reset($tab);
}

Expected result:
----------------
import all the session variable
AND the session should still save correctly

Actual result:
--------------
imports all the session variables
BUT sessions ARE NOT saved


Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-20 11:14 UTC] sniper@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

Try the latest STABLE snapshot from http://snaps.php.net/

 [2003-07-20 11:15 UTC] sniper@php.net
Uh..and RTFM about how superglobals work..

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Aug 15 19:01:28 2024 UTC