Well the class needs to be declared before the session is started...
so make sure that you don't call session_start before
your User class is defined.... and... make sure sessions_auto_start in you
php.ini is set to false
- Brad
--- [EMAIL PROTECTED] wrote:
> From: [EMAIL PROTECTED]
> Operating system: win 98/PWS
> PHP version: 4.1.1
> PHP Bug Type: Session related
> Bug description: objects in sessions
>
> 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 bug report at http://bugs.php.net/?id=15525&edit=1
> --
> Fixed in CVS: http://bugs.php.net/fix.php?id=15525&r=fixedcvs
> Fixed in release: http://bugs.php.net/fix.php?id=15525&r=alreadyfixed
> Need backtrace: http://bugs.php.net/fix.php?id=15525&r=needtrace
> Try newer version: http://bugs.php.net/fix.php?id=15525&r=oldversion
> Not developer issue: http://bugs.php.net/fix.php?id=15525&r=support
> Expected behavior: http://bugs.php.net/fix.php?id=15525&r=notwrong
> Not enough info: http://bugs.php.net/fix.php?id=15525&r=notenoughinfo
> Submitted twice: http://bugs.php.net/fix.php?id=15525&r=submittedtwice
>
__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php