note 71125 rejected from ref.session by bobby
| From: | bobby@php.net | Date: | Mon, 13 Nov 2006 16:10:32 +0000 |
| Subject: | note 71125 rejected from ref.session by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-119668@lists.php.net to get a copy of this message | ||
Note Submitter: bartek at cpu-zeto dot com dot pl
----
There is a PROBLEM, mayby BUG with session $_SESSION. If you assign $_SESSION to variable you
can'not register more data after assignment and it differs even on kind of variable.
1. NORMAL
//From Session:
print_r($_SESSION);
$_SESSION["test1"] = "test1";
//$var = $_SESSION; //variable or self::$var = $_SESSION
$_SESSION["test2"] = "test2";
//From Assignments:
print_r($_SESSION);
/*
//Before reload page:
//From Session obviously Nothing
//From Asinments of course:
Array
(
[test1] => test1
[test2] => test2
)
//And after post page you get of course:
//From Session
Array
(
[test1] => test1
[test2] => test2
)
//From Asinments of course:
Array
(
[test1] => test1
[test2] => test2
)
WRONG SOME BUGS - But if you assign $_SESSION to variable some sheet heppens:
//self::$var = $_SESSION //static variable for ex. within some static method between sessions
assignment;
$_SESSION["test1"] = "test2...";
self::$var = $_SESSION
$_SESSION["test2"] = "test2...";
//You get before:
Array
(
[test1] => test1
[test2] => test2
)
Array
(
[test1] => test1...
[test2] => test2...
)
//And after reload
Array
(
[test1] => test1... // as you see only one variable was assign
[test2] => test2 // - BUG
)
Array
(
[test1] => test1...
[test2] => test2...
)
//AND EVEN MORE strange things, if you assign local varaiable you cant change $_SESSION after and
before:
$_SESSION["test1"] = "test2.............";
self::$var = $_SESSION
$_SESSION["test2"] = "test2.............";
//You get before:
Array
(
[test1] => test1...
[test2] => test2
)
Array
(
[test1] => test1..............
[test2] => test2..............
)
//And After
Array
(
[test1] => test1... //NOTHING WAS CHANGED
[test2] => test2
)
Array
(
[test1] => test1..............
[test2] => test2..............
)
I have a question: IS IT A BUG OR AM I DOIN'G SOMETHING WRONG ???? But i have found workaround,
if somebody is interested; do cast to object when you assign
like that: $var = (object)$_SESSION or self::$var = (object)$_SESSION