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

From: Date: Sat, 27 Oct 2012 09:08:50 +0000
Subject: Bug #63375 [Opn]: Pointer to the session dosnt work properly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-174378@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63375&edit=1 ID: 63375 User updated by: dino2150 at poczta dot fm Reported by: dino2150 at poczta dot fm Summary: Pointer to the session dosnt work properly Status: Open Type: Bug Package: Session related Operating System: Win XP64 PHP Version: 5.4Git-2012-10-27 (snap) Block user comment: N Private report: N New Comment: Btw: My version is 5.4.3 if it helps! Previous Comments: ------------------------------------------------------------------------ [2012-10-27 09:06:26] dino2150 at poczta dot fm 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 this bug report at https://bugs.php.net/bug.php?id=63375&edit=1

« previous php.bugs (#174378) next »