|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64724 Objects stored in Sessions sometimes get "lost".
Submitted: 2013-04-26 15:04 UTC Modified: 2013-07-29 13:37 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: php dot bugs at lippe-net dot de Assigned: mike (profile)
Status: No Feedback Package: *General Issues
PHP Version: 5.4.14 OS: Debian Wheezy
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
26 + 8 = ?
Subscribe to this entry?

 [2013-04-26 15:04 UTC] php dot bugs at lippe-net dot de
The "transactions" array of the $_SESSION variable is initialized only once.

If you repeat the invocation of the script. After a while the array contains some 
elements that are no more Objects of "class S" but references (for example 

Test script:

class S implements \Serializable {

	protected $data = [];

	public function __construct() {
		for ( $i = 0; $i <= mt_rand(4, 7); $i++ ) {
			$this->data[] = mt_rand(0, 50);

	public function serialize() {
		return serialize($this->data);

	public function unserialize($data) {
		$this->data = unserialize($data);



if ( empty($_SESSION["transactions"]) ) {
	$_SESSION["transactions"] = [ new S(), new S(), new S(), new S() ];

echo serialize($_SESSION);


Expected result:
Example (first call):

Actual result:
Example (after some roundabout 50 calls):



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-04-27 15:45 UTC]
-Package: Session related +Package: *General Issues -Assigned To: +Assigned To: mike
 [2013-04-27 15:45 UTC]
maybe due to the serialize
 [2013-04-29 14:15 UTC]
-Status: Assigned +Status: Feedback
 [2013-04-29 14:15 UTC]
Can't reproduce.

Do you have any special extensions loaded? If so, see if that also happens without them loaded.
 [2013-05-06 16:20 UTC] php dot bugs at lippe-net dot de
The only thing is a DBG v4.6.4 installation, but it seems to make no difference if it is activated or not.
 [2013-05-07 09:46 UTC]
It "seems", or it "does"?

Is this a ZTS build?

 [2013-05-07 10:45 UTC] php dot bugs at lippe-net dot de
The debian libapache2-mod-php5 (5.4.4-14) is certainly not thread-safe.
 [2013-07-05 12:58 UTC]
So does this happen if you do not even load DBG?
 [2013-07-29 13:37 UTC]
-Status: Feedback +Status: No Feedback
 [2013-07-29 13:37 UTC]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 02:01:35 2024 UTC