note 33204 added to ref.session
| From: | fred at lrc dot puissante dot com | Date: | Thu, 19 Jun 2003 05:29:58 +0000 |
| Subject: | note 33204 added to ref.session | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-50618@lists.php.net to get a copy of this message | ||
Important note about sessions and objects:
If you set $_SESSION[] to an object that has a circular reference, the session may not be written
out. That is to say that persistence will fail.
Example:
===============
<?php
class foo
{
var $bar;
}
class bar
{
var $foo;
}
session_start();
$f = new foo;
$b = new bar;
$f->bar =& $b;
$b->foo =& $f;
$_SESSION['foobar'] =& $f;
?>
================
A side note is that doing a print_r($f) will go in a endless loop, bringing the server down to its
knees (by chewing up all memory, CPU, and flooding output) unless you restart Apache.
PHP 4.3.1, 4.3.2, RedHat 9 Linux
----
Manual Page -- http://www.php.net/manual/en/ref.session.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33204
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33204&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33204&report=yes