php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3261 sess_register doesn't register global variables correctly
Submitted: 2000-01-20 12:40 UTC Modified: 2000-11-19 08:14 UTC
From: stas at zend dot com Assigned: stas (profile)
Status: Closed Package: *General Issues
PHP Version: 4.0 Latest CVS (20/01/2000) OS: Linux
Private report: No CVE-ID: None
 [2000-01-20 12:40 UTC] stas at zend dot com
The script:

<?php

session_name("XSession");

function start() {
global $count;
session_start();
session_register("count");
var_dump($count);
}


function see() {
global $count;
print "Here: $count<br>";
}

$count=0;
start();
see();
$count++;
?>

shows:

int(0) Here: N

where N is the correct current value of $count.  Note that if I put global after session_register, it works OK.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-05-13 11:33 UTC] sterling at cvs dot php dot net
Session variables are not in the global namespace unless specified.  This is the correct behavior.
 [2000-05-14 04:33 UTC] stas at zend dot com
What do you mean "unless specified"? Did you look at the code:

function start() {
                            global $count;
// If *this* is not specification of global, what is?
                            session_start();
                            session_register("count");
                            var_dump($count);
// Which "count" is 0 here? If global, why it isn't 0 below?
// If local, what happened to "global" $count I just defined and
// how do I specify that I want *that* *global* count, and not 
// want to create new local one to override old one? 
                           }

function see() {
                            global $count;
                            print "Here: $count<br>";
// And *how exactly* I got the right value here if session variable wasn't global?

                            }

 [2000-05-14 04:34 UTC] stas at zend dot com
What do you mean "unless specified"? Did you look at the code:

function start() {
                            global $count;
// If *this* is not specification of global, what is?
                            session_start();
                            session_register("count");
                            var_dump($count);
// Which "count" is 0 here? If global, why it isn't 0 below?
// If local, what happened to "global" $count I just defined and
// how do I specify that I want *that* *global* count, and not 
// want to create new local one to override old one? 
                           }

function see() {
                            global $count;
                            print "Here: $count<br>";
// And *how exactly* I got the right value here if session variable wasn't global?

                            }

 [2000-07-30 09:46 UTC] zak@php.net
Has there been any progress on this bug?
 [2000-08-15 09:38 UTC] waldschrott@php.net
This is a dup.
 [2000-08-15 10:28 UTC] waldschrott@php.net

 [2000-08-15 10:29 UTC] waldschrott@php.net

 [2000-11-19 08:14 UTC] stas@php.net
Fixed in CVS.

 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC