note 43641 deleted from function.serialize by irchtml

From: Date: Wed, 12 Jan 2005 10:46:11 +0000
Subject: note 43641 deleted from function.serialize by irchtml
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-83133@lists.php.net to get a copy of this message
Note Submitter: Andrew dot Morrison at stanford dot edu ---- If there is good documentation for __sleep() and __wakeup(), I haven't found it. It looks like (after some trial and error) you have to return $this from __sleep(), or your data will go missing. An example: <?php class strawman { function __sleep() { print "Function __sleep() called\n"; return $this; /* The missing ingredient */ } function __wakeup() { print "Function __wakeup() called\n"; } function strawman() { } } session_start(); if(session_is_registered('strawman')) { print("session data:\n"); print_r($_SESSION['strawman']); session_destroy(); } else { $strawman =& new strawman(); session_register('strawman'); print("new session data:\n"); print_r($_SESSION['strawman']); } ?>

« previous php.notes (#83133) next »