By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,009 Members | 1,767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,009 IT Pros & Developers. It's quick & easy.

Mojavi 2.0 PHP4 Problem with object storage

P: n/a
Hello,

I need to store in user session an instance of an OWN class, "Foo",
for example.
Its works inside a single action but the object doesn't "survive"
between two actions (1)
Trying to access this object in the second action display :

Fatal error: Unknown(): The script tried to execute a method or access
a property of an incomplete object. Please ensure that the class
definition "Foo" of the object you are trying to operate on was loaded
_before_ the session was started

Thanks a lot for your help and ideas !

(1)
In the first action :
require_once ('Foo.php');
$foo = new Foo ();
$user->setAttribute ("foo", $foo, "my-user-namespace");

The following ... ok in the first action, but not in a second action
$newfoo = $user->getAttribute ("foo","my-user-namespace");
$newfoo->bar ();
Jan 8 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Tue, 08 Jan 2008 12:51:41 +0100, ezahn <ev**********@gmail.comwrote:
Hello,

I need to store in user session an instance of an OWN class, "Foo",
for example.
Its works inside a single action but the object doesn't "survive"
between two actions (1)
Trying to access this object in the second action display :

Fatal error: Unknown(): The script tried to execute a method or access
a property of an incomplete object. Please ensure that the class
definition "Foo" of the object you are trying to operate on was loaded
_before_ the session was started

Thanks a lot for your help and ideas !

(1)
In the first action :
require_once ('Foo.php');
$foo = new Foo ();
$user->setAttribute ("foo", $foo, "my-user-namespace");

The following ... ok in the first action, but not in a second action
$newfoo = $user->getAttribute ("foo","my-user-namespace");
$newfoo->bar ();
1. Be sure you have loaded the class definition before session_start(), do
NOT trust __autoload().
2. References won't survive serialisation (which is how most sessions are
stored).
3. Look at the manual regarding objects & serialisation (and their
associated magic methods..)
--
Rik Wasmus
Jan 8 '08 #2

P: n/a
On 8 jan, 12:51, ezahn <evelyne.z...@gmail.comwrote:
Hello,

I need to store in user session an instance of an OWN class, "Foo",
for example.
Its works inside a single action but the object doesn't "survive"
between two actions (1)
Trying to access this object in the second action display :

Fatal error: Unknown(): The script tried to execute a method or access
a property of an incomplete object. Please ensure that the class
definition "Foo" of the object you are trying to operate on was loaded
_before_ the session was started

Thanks a lot for your help and ideas !

(1)
In the first action :
require_once ('Foo.php');
$foo = new Foo ();
$user->setAttribute ("foo", $foo, "my-user-namespace");

The following ... ok in the first action, but not in a second action
$newfoo = $user->getAttribute ("foo","my-user-namespace");
$newfoo->bar ();
Jan 8 '08 #3

P: n/a
On 8 jan, 13:14, "Rik Wasmus" <luiheidsgoe...@hotmail.comwrote:
On Tue, 08 Jan 2008 12:51:41 +0100, ezahn <evelyne.z...@gmail.comwrote:
Hello,
I need to store in user session an instance of an OWN class, "Foo",
for example.
Its works inside a single action but the object doesn't "survive"
between two actions (1)
Trying to access this object in the second action display :
Fatal error: Unknown(): The script tried to execute a method or access
a property of an incomplete object. Please ensure that the class
definition "Foo" of the object you are trying to operate on was loaded
_before_ the session was started
Thanks a lot for your help and ideas !
(1)
In the first action :
require_once ('Foo.php');
$foo = new Foo ();
$user->setAttribute ("foo", $foo, "my-user-namespace");
The following ... ok in the first action, but not in a second action
$newfoo = $user->getAttribute ("foo","my-user-namespace");
$newfoo->bar ();

1. Be sure you have loaded the class definition before session_start(), do
NOT trust __autoload().
2. References won't survive serialisation (which is how most sessions are
stored).
3. Look at the manual regarding objects & serialisation (and their
associated magic methods..)
--
Rik Wasmus
Yes, it works better with the "include" before the session_start
(arggh sorry !) and without references ... Thanks a lot !:-)
Jan 8 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.