Marcos R. Cardoso wrote:
i'd try using serialize() to turn the object into a string which can
then be put in the session, and then unserialize() when you want it back
out again
sessions work by using cookies, and cookies can't take php objects
;)
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
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php