php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15525 objects in sessions
Submitted: 2002-02-12 10:48 UTC Modified: 2002-02-12 20:07 UTC
From: dancimpoiesu at gmx dot net Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.1.1 OS: win 98/PWS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dancimpoiesu at gmx dot net
New email:
PHP Version: OS:

 

 [2002-02-12 10:48 UTC] dancimpoiesu at gmx dot 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;
}
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-12 20:07 UTC] yohgaki@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 16:01:36 2024 UTC