Question

I have two namespaces in my session: "global" and "user"

In "global" there are just a few settings and in "user" i have a serialized user-object which I guess is saved correctly: (This is from the sessionfile)

global|a:16:{ [...] s:12:"last_request";i:1301390173; [...] }

user|a:1:{ s:10:"userObject";O:16:"currentUserModel":24:{ [...] s:10:"*_roleId";s:7:"premium"; [...] } }

When I do this: $sess = new Zend_Session_Namespace('global');

I get an error about including "currentUserModel.php" which I don't want because I don't need the userobject at this point - all I want to do is get my "global" namespace.

Now the question is: Do I have to include all classes for all objects stored in all my namespaces or is it possible to include just the classes for the objects that are in the namespace I'm accessing?

Thanks in advance

Was it helpful?

Solution

The namespace in Zend_Session is just a layer on top of the $_SESSION global variable. In php, these namespaces don't exist. In Zend_Session, the namespace is a key from a associate array.

Thus, when you load a session namespace, you load in fact the whole $_SESSION, except you cannot access other "namespaces" through this Zend_Session. So yes: you need to include the file currentUserModel.php before the session.

Another method is to use properly the __sleep() and __wakeup() magic methods from the class to serialize only the properties of a class as an associative array and then you're afaik ready to go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top