note 60926 deleted from ref.session by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: pascal.fr => gmail.com 

----

If you have saved an object in session, you must define the class of the object before the session_start().
If you don't do that, php will not know the class of the object, and his type will be "__PHP_Incomplete_Class".

This:
<?php
session_start();

class Foo{
    var $fooVar = 'Hello world !!!';
}

$myFoo = new Foo();
$_SESSION['myFoo'] = $myFoo;
echo 'Save in session';
?>
define the Foo class and save an instance  in session.

<?php
session_start();

echo '<pre>';
    print_r( $_SESSION ); // don't know the Foo class...
echo '</pre>';
?>

will print : 

Array
(
    [myFoo] => __PHP_Incomplete_Class Object
        (
            [__PHP_Incomplete_Class_Name] => foo
            [fooVar] => Hello world !!!
        )

)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.