note 56172 added to function.session-set-save-handler

From: Date: Thu, 25 Aug 2005 20:34:45 +0000
Subject: note 56172 added to function.session-set-save-handler
Groups: php.notes 
Request: Send a blank email to php-notes+get-94194@lists.php.net to get a copy of this message
When creating a session-handling class, I have discovered that it is important to remember that your session object and the $_SESSION global are TWO SEPARATE ENTITIES. You need to create a reference between your Session Object and the built-in $_SESSION global: session_set_save_handler( array(&$this, "_OPEN"), array(&$this, "_CLOSE"), array(&$this, "_READ"), array(&$this, "_WRITE"), array(&$this, "_DESTROY"), array(&$this, "_GC") ); session_start(); header("Cache-control: private"); // to overcome/fix a bug in IE 6.x $this->session =& $_SESSION; Additionally, when you add a $_SESSION variable, it's a good idea to add it as a Session Object variable at the same time, if you want your code to use the Session Object between page changes/reloads: function setSessionVariable($key,$value) { $_SESSION[$key] = $value; $this->session[$key] = $value; return; } ---- Manual Page -- http://www.php.net/manual/en/function.session-set-save-handler.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56172 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56172&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56172&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56172&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56172&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56172&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56172&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56172&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94194) next »