Bug #63375 [NEW]: Pointer to the session dosnt work properly

From: Date: Sat, 27 Oct 2012 09:06:26 +0000
Subject: Bug #63375 [NEW]: Pointer to the session dosnt work properly
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-174377@lists.php.net to get a copy of this message
From: dino2150 at poczta dot fm Operating system: Win XP64 PHP version: 5.4Git-2012-10-27 (snap) Package: Session related Bug Type: Bug Bug description:Pointer to the session dosnt work properly Description: ------------ What I'm actually trying to do is to create pointer to session. Ok. Piece of cake. STEP:1 ---------------- session_start(); $a = &$_SESSION; $a[5] = 555; -> RUN THE SCRIPT NOW; back to edit: session_start(); $a = &$_SESSION; $a[5] = 555; print_r($_SESSION); this echoes correctly ;) STEP:2 ----------------- Let's try to zero-memory session data. session_start(); $a = &$_SESSION; $_SESSION=NULL; $a[5] = 55; $_SESSION['abc']=555; print_r($_SESSION); At this point $_SESSION contains two elements. No wonder, right? Yea..right... Now back to edit: session_start(); print_r($_SESSION); At this point session contains only ONE element? WTF happend to the $_SESSION[5]=55; it was there before... My first shot was to unset session data with session_unset so i repleaced SESSION=NULL with session_unset(). This gives me the same effect. I also took a chance with session_destroy ;) but then the SESSION table was empty (and that makes perfecly sense). However its hard to understand why $_SESSION table is saved partialy and not including values setted by $_SESSION reference, and WHY THIS ONLY HAPPEND WHEN I DO SOMETHING WITH THIS TABLE to erase it ;P Test script: --------------- TEST SCIRPT IS PART OF DESCRIPTION. Expected result: ---------------- All variables setted by SESSION reference after calling session_unset() are expected to stay in SESSION. So: first i make session ref: $a = &$_SESSION; then i zero-memory session by session_unset(); then i set something to session by ref. $a[5]=55; and i expected this to stay in session. Actual result: -------------- If i use session_unset() or nullarize session by $_SESSION=NULL and then set variables by session reference...The variables set by session reference are gone after script ends. -- Edit bug report at https://bugs.php.net/bug.php?id=63375&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63375&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63375&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63375&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63375&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63375&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63375&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63375&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63375&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63375&r=support Expected behavior: https://bugs.php.net/fix.php?id=63375&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63375&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63375&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63375&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63375&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63375&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63375&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63375&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63375&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63375&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63375&r=mysqlcfg

« previous php.bugs (#174377) next »