php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32869 Session and reference related
Submitted: 2005-04-28 17:31 UTC Modified: 2005-04-29 01:09 UTC
From: thomas dot ene at gmail dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.3.9 OS: Windows
Private report: No CVE-ID: None
 [2005-04-28 17:31 UTC] thomas dot ene at gmail dot com
Description:
------------
Let's say I have a class c1. Doing this:

$obj = &$_SESSION['obj'];
$obj = &new c1();

would set $_SESSION['obj'] to NULL.

Reproduce code:
---------------
<?php
class c1
{
	var $v;
	function c1($a)		{ $this->v = $a; }
	function say()		{ print "{$this->v}<br>"; }
}
	
session_start();
session_destroy();
	
$obj = &$_SESSION['aaa'];
$obj = &new c1(6);
	
var_dump($_SESSION['aaa']);
?>

Expected result:
----------------
I would expect to have an object in the $_SESSION['aaa']

Actual result:
--------------
The actual result is NULL. Sorry if this is post in not pertinent but I haven't found any support related to this.

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-29 01:09 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

This has nothing to do with sessions. (same happens if you replace $_SESSION['aaa'] with e.g. $bar)

Please read this manual page and try to understand how references work:

http://www.php.net/manual/en/language.references.php

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Aug 14 07:01:28 2024 UTC