Handling objects as session vars

From: Date: Mon, 10 Oct 2005 19:36:42 +0000
Subject: Handling objects as session vars
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-26391@lists.php.net to get a copy of this message
I'm trying to use an object as a session var so I could handle its properties and methods as long as the session is still on. But when I use a second PHP script the values inside this object are lost. I have a script like this. <? include("class/object_def.php"); session_start(); $new_object = new TNewClass($cod,$password); if ($new_object->getCod() == 0) { echo $new_object->getMsgError(); } else { $_SESSION['session_object'] = $new_object; ?> <script language="JavaScript"> location.replace("new_script.php"); </script> <? } ?> then in the script "new_script.php" I have the following instructions: <? include("class/object_def.php"); session_start(); if ($_SESSION['session_object'] == "") { echo "there is no session open<br>"; exit; } echo $_SESSION['session_object']->getCod()."<br>"; echo $_SESSION['session_object']->getName()."<br>"; ?> The result from the script new_script.php always return empty where the methods should return something. I've already read the documentation at www.php.net, tried what it's shown there and checked some other sites as well, bu I haven't found a solution yet. Environment: Windows 2003 Server Apache 2.0.54 PHP 4.4.0 Sun Chili!Soft ASP 3.6.2 MySQL 4.0.20a Oracle 9i (through a Oracle 8i NetClient) TIA, Marcos R. Cardoso Blumenau Brazil

« previous php.windows (#26391) next »