php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12600 Session_register & register_globals=off ---> strange behaviour?
Submitted: 2001-08-06 11:23 UTC Modified: 2001-11-24 19:44 UTC
From: tr909 at bigfoot dot com Assigned:
Status: Closed Package: Session related
PHP Version: 4.0.6 OS: linux redhat 7.1
Private report: No CVE-ID: None
 [2001-08-06 11:23 UTC] tr909 at bigfoot dot com
1. when register_globals is off you have to
SET and READ HTTP_SESSION_VARS this is wrong in the docs or 
at least confusing (example 1 on
http://www.php.net/manual/en/ref.session.php )

BUG
2. session_register cannot be called from inside another 
funcion (when trying a by reference call this generates a 
call-time reference error on some servers)

 function & sess_reg($x){
 global $HTTP_SESSION_VARS;
   session_register(& $HTTP_SESSION_VARS[$x]);
   $GLOBALS[$x] = & $HTTP_SESSION_VARS[$x];
 }
 //session_start();
 sess_reg("foo");
 echo $foo++;

when using session_register($HTTP_SESSION_VARS[$x]);
the variable is NOT registered. and when used by reference 
(as in example above) generates a "Warning: Call-time 
pass-by-reference has been deprecated - 
argument passed by value;"

Tr909

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-06 11:40 UTC] tr909 at bigfoot dot com
function sess_reg($x){
global $HTTP_SESSION_VARS;
   $a = & $HTTP_SESSION_VARS[$x];
   session_register($a);
   echo $a;
   $GLOBALS[$x] = & $HTTP_SESSION_VARS[$x];
}  

this seems to work but it is still strange that
  session_register("$HTTP_SESSION_VARS[$x]"); 
or even
  session_register("$HTTP_SESSION_VARS["foo");
do not work inside a function.

even more strange
is that HTTP_SESSION_VARS[$x] does not even exist
at the time you set a reference to it? maybe, i'm
curious now, that session_register() doesn't like
arrays but with register_globals = off you just have
the SESSION-VARS array

 [2001-08-06 15:39 UTC] jeroen@php.net
Fixed title, didn't verify this.
 [2001-11-24 19:44 UTC] sniper@php.net
Use $_SESSION[] which is introduced in PHP 4.1.0.
Latest RC can be found here:

http://www.php.net/~zeev/php-4.1.0RC3.tar.gz
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Sep 17 07:01:28 2024 UTC