Re: Register globals and ini_set

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I was setting the $_SESSION by:
$_SESSION['var_name'] = "this";
or 
$my_local = "this";
$_SESSION['var_name'] = $my_local;

I had stopped using session_register() some time back.

"Sporatically" meaning that some of my variables are working fine, while others seem to become empty when referenced by a later script. These scripts were working fine on the older PHP version. I'm sure it's just a quick determination as to what to change, and then I can do a global update across the site. There are about 20-30 websites that this affects, so you can see my frustration in trying to do this by bits and pieces. I had done a test file like this:

test1.php:
<?php
  $_SESSION['check'] = "test 1";
  echo($_SESSION['check']);
?>
<a href='test2.php'>Click</a>

and
test2.php:
<?php
  echo($_SESSION['check']);
?>
test1.php displays "test1" but test2.php displays nothing.

Terry

-----Original Message-----
From: Jason Barnett <jason.barnett@xxxxxxxxxxxxx>
Sent: Jul 8, 2005 9:15 AM
To: php-general@xxxxxxxxxxxxx
Subject: Re:  Register globals and ini_set

Since you mention the PHP version was old (4.1) then I have to ask: were 
you using the $_SESSION array all along or were you using 
session_register to register session variables?  Although you probably 
aren't since that would be rather easy to debug.

The script in which your global_variable was set makes absolutely no 
difference.  PHP is just looking for the SID someplace anyways (whether 
that's COOKIE, GET or POST) and then it goes and retrieves that session 
that matches that SID.

OK... when you say that it fails sporadically, what do you mean exactly?

Probably, based on what you've just said, you're somehow assigning into 
your $_SESSION variables through the use of global variables that have 
the same name as your $_SESSION indexes.

http://php.net/manual/en/ref.session.php#ini.session.bug-compat-42


-- 
NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
STFA | http://marc.theaimsgroup.com/?l=php-general&w=2
STFM | http://php.net/manual/en/index.php
STFW | http://www.google.com/search?q=php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux