php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12236 session_start() inside a function destroys reference to $HTTP_SESSION_VARS
Submitted: 2001-07-18 16:08 UTC Modified: 2001-11-24 19:41 UTC
From: b dot erdmann at 4commerce dot de Assigned:
Status: Closed Package: Session related
PHP Version: 4.0.6 OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
10 + 45 = ?
Subscribe to this entry?

 
 [2001-07-18 16:08 UTC] b dot erdmann at 4commerce dot de
The following code doesn't work

<?php
  function start_session() {
    global $HTTP_SESSION_VARS;
    session_start();
    echo $HTTP_SESSION_VARS["testvar"];
  }
  start_session();
?>

while this one does

<?php
  function start_session() {
    session_start();
    global $HTTP_SESSION_VARS;
    echo $HTTP_SESSION_VARS["testvar"];
  }
  start_session();
?>
Obviosly after session_start() $HTTP_SESSION_VARS is not
global any more.

(register_globals Off)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-24 19:41 UTC] sniper@php.net
This problem will be gone in PHP 4.1.0 (and more probs are 
fixed for 4.2.0). In PHP 4.1 we have introduced new TRUE
global variables and one of them is:

$_SESSION (same as $HTTP_SESSION_VARS but is true global)

--Jani

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 05:01:32 2024 UTC