note 102958 added to function.session-write-close

From: Date: Wed, 16 Mar 2011 21:31:22 +0000
Subject: note 102958 added to function.session-write-close
Groups: php.notes 
Request: Send a blank email to php-notes+get-177943@lists.php.net to get a copy of this message
@joadha at gmail dot com: That is completely and entirely incorrect. Serialized objects do retain their private and protected members. <?php class Foo { private $bar; public $baz; public function setBar($data) { $this->bar = $data; } public function getBar() { return $this->bar; } } $f = new Foo(); $f->setBar("I am Bar"); $f->baz = "I am Baz"; $s = serialize($f); echo $s; $not_f = unserialize($s); echo $not_f->getBar(); // "I am Bar" ?> Now, it happens that private and protected members get null bytes prepended to their names, but that should not impact anything whatsoever as long as you store them in a way that won't get disrupted by the null byte. You can even safely strip the null byte from the name and still get the data restored properly. ---- Server IP: 192.41.42.26 Probable Submitter: 72.249.185.28 ---- Manual Page -- http://www.php.net/manual/en/function.session-write-close.php Edit -- https://master.php.net/note/edit/102958 Del: integrated -- https://master.php.net/note/delete/102958/integrated Del: useless -- https://master.php.net/note/delete/102958/useless Del: bad code -- https://master.php.net/note/delete/102958/bad+code Del: spam -- https://master.php.net/note/delete/102958/spam Del: non-english -- https://master.php.net/note/delete/102958/non-english Del: in docs -- https://master.php.net/note/delete/102958/in+docs Del: other reasons-- https://master.php.net/note/delete/102958 Reject -- https://master.php.net/note/reject/102958 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#177943) next »