Bug #15525 Updated: objects in sessions
ID: 15525
Updated by: yohgaki@php.net
Reported By: dancimpoiesu@gmx.net
-Status: Open
+Status: Bogus
Bug Type: Session related
Operating System: win 98/PWS
PHP Version: 4.1.1
New Comment:
The bug system is not the appropriate forum for asking support
questions. For a list of a range of more appropriate places to ask
for help using PHP, please visit http://www.php.net/support.php
Class definition must be defined before session is started.
Previous Comments:
------------------------------------------------------------------------
[2002-02-12 10:48:40] dancimpoiesu@gmx.net
I tried to use objects in session variables, but when i try to catch
and print their properties into another page there is the following
error:
Fatal error: The script tried to execute a method or access a property
of an incomplete object. Please ensure that the class definition user
of the object you are trying to operate on was loaded _before_ the
session was started in C:\Inetpub\wwwroot\Mail\mail2.php on line 13
I mention that i include a script defining the class structure in both
of the pages below.
Also I used the functions serialize() and unserialize(), and it works
fine with them, but in documentation it sais that when jumping between
two pages in a session the objects are serialized automatically !
There are the 3 files that i use, in a win 98 environment, with php
4.1.1 installed with the default configuration and default php.ini, and
set up to include automatically in url the session id.
*******mail.php*******
<?php
include("class.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>MailBox</title>
</head>
<body>
<?php
$objLogin=new User;
$objLogin->User="DanMaster";
$objLogin->Password="test";
session_register("objLogin");
echo "User={$objLogin->User}<br>";
echo "Password={$objLogin->Password}<br>";
?>
To continue, <A HREF="mail2.php">click here</A>
</body>
</html>
*******mail2.php*******
<?php
include("class.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<?php
global $objLogin;
?>
User=<?php echo $objLogin->User?><br>
Password=<?php echo $objLogin->Password?>
</body>
</html>
*******class.php*******
<?php
class User {
var $User;
var $Password;
}
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=15525&edit=1
Thread (2 messages)