php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #36173 Static Variable Not saved when object saved in $_Session
Submitted: 2006-01-26 20:36 UTC Modified: 2006-01-26 20:52 UTC
From: ismell at ismell dot org Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.1.2 OS: Linux 2.6
Private report: No CVE-ID: None
 [2006-01-26 20:36 UTC] ismell at ismell dot org
Description:
------------
Then saving an object with a static variable in a session, when the session is reloaded, the variable is not set anymore.

Reproduce code:
---------------
<?php
session_start();

class c1 {
	public static $ids = 1;
	private $id;
	
	public function __construct() {
		$this->id = c1::$ids++;
	}
	public function getId() {
		return $this->id;
	}
} 
$_SESSION['test'][] = new c1();
$_SESSION['test'][] = new c1();
echo '<pre>Output:';

foreach ($_SESSION['test'] as $class) {
	echo $class->getId()."\n";
}
echo '</pre>'

?>

Expected result:
----------------
Output:
1
2
3
4
5
6
7
8
9

Actual result:
--------------
Output:
1
2
1
2
1
2
1
2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-26 20:52 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

you stored objects
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 29 09:01:33 2024 UTC