php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63375 Pointer to the session dosnt work properly
Submitted: 2012-10-27 09:06 UTC Modified: 2012-10-27 15:51 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dino2150 at poczta dot fm Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.4Git-2012-10-27 (snap) OS: Win XP64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dino2150 at poczta dot fm
New email:
PHP Version: OS:

 

 [2012-10-27 09:06 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-27 09:08 UTC] dino2150 at poczta dot fm
Btw: My version is 5.4.3 if it helps!
 [2012-10-27 09:45 UTC] dino2150 at poczta dot fm
The problem was different then described.
SESSION just cant contain numerical keys...
Din't know that before.
 [2012-10-27 09:45 UTC] dino2150 at poczta dot fm
-Status: Open +Status: Closed
 [2012-10-27 15:51 UTC] rasmus@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 02:01:35 2024 UTC