php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16273 $_SESSION won't work when register_globals is OFF!
Submitted: 2002-03-25 19:53 UTC Modified: 2002-04-10 19:15 UTC
From: anarres at gmx dot net Assigned:
Status: Closed Package: Session related
PHP Version: 4.1.2 OS: Windows 98 SE German
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: anarres at gmx dot net
New email:
PHP Version: OS:

 

 [2002-03-25 19:53 UTC] anarres at gmx dot net
Two days ago I installed PHP Version 4.1.2 as CGI on a Win98SE platform with Apache 1.3.20 running as server. I used the php.ini-recommended with register_globals turned OFF and made only minor changes concerning directories and error-display. Migrating my old scripts to the new settings I found that the session management with the superglobal $_SESSION would not work: the session file was created in my session directory (session.save_path=c:\tmp) BUT no session variables were stored in it.

Here's a pair of scripts to illustrate:

session_1.php:
        <?php
            session_start();
            $_SESSION['text']="Hallo!";
            echo '<a href="session_2.php">session_2.php</a>';
        ?>

session_2.php:
        <?php
            session_start();
            echo $_SESSION['text'];
        ?>

On activating the link to session_2.php, the following errormessage is displayed:

        Warning: Undefined index: text in session_2.php on line 3

(Using $HTTP_SESSION_VARS['text'] instead of $_SESSION['text'] leads to the same result.)

However, turning register_globals ON and using global variables with session_register(), session_unregister() and session_is_registered() works fine. But that's not really the point of php.ini-recommended, is it? ;-)-:

After spending many hours checking my setup, reading the manual and several faqs and finally receiving feedback from other users who have the same problem on the german PHP-mailinglist php@phpcenter.de and not finding it  this bug in your list of reported bugs, I decided to report it. I also thought that this is a rather major problem, since register_globals is to be turned off by default in upcoming versions. Please contact me if you need any additional information - this is the first time I am reporting a bug.

Thanx 4 your great work,
Robert

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-25 20:15 UTC] anarres at gmx dot net
Two days ago I installed PHP Version 4.1.2 as CGI on a Win98SE platform
   with Apache 1.3.20 running as server. I used the php.ini-recommended
   with register_globals turned OFF and made only minor changes concerning
   directories and error-display. Migrating my old scripts to the new
   settings I found that the session management with the superglobal
   $_SESSION would not work: the session file was created in my session
   directory (session.save_path=c:\tmp) BUT no session variables were
   stored in it.

   Here's a pair of scripts to illustrate:

   session_1.php:
           <?php
               session_start();
               $_SESSION['text']="Hallo!";
               echo '<a href="session_2.php">session_2.php</a>';
           ?>

   session_2.php:
           <?php
               session_start();
               echo $_SESSION['text'];
           ?>

   On activating the link to session_2.php, the following errormessage is
   displayed:

           Warning: Undefined index: text in session_2.php on line 3

   (Using $HTTP_SESSION_VARS['text'] instead of $_SESSION['text'] leads to
   the same result.)

   However, turning register_globals ON and using global variables with
   session_register(), session_unregister() and session_is_registered()
   works fine. But that's not really the point of php.ini-recommended, is
   it? ;-)-:

   After spending many hours checking my setup, reading the manual and
   several faqs and finally receiving feedback from other users who have
   the same problem on the german PHP-mailinglist php@phpcenter.de and not
   finding it  this bug in your list of reported bugs, I decided to report
   it. I also thought that this is a rather major problem, since
   register_globals is to be turned off by default in upcoming versions.
   Please contact me if you need any additional information - this is the
   first time I am reporting a bug.

   Thanx 4 your great work,
   Robert
 [2002-04-10 19:15 UTC] sniper@php.net
This bug has been fixed in CVS.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 08:01:30 2025 UTC