![]() |
storing class instance into session
Do you think SetObject() method will work?
PHP Code:
|
Its possible to serialize object instances and store them in session variables, you just have to remember to include the class declaring before the session_start() call, else deserialized instances will become an instance of __PHP_Incomplete_Class.
|
yes, before session
Dear Kalle
Thanks for quick reply. Then my method will not work, because I am trying to store the FooBar class into $_SESSION var AFTER the session is created. I see this is the problem. Now, how about this? is this the right way of applying the params to a CLASS (not a function) $obj_ins = call_user_func_array($class_name, $params); thank you |
I found my own solution
YES! you can store object instance into session AFTER session initialization.
THE WHOLE trick resides in these lines (requires php v5.1.3): $reflection_obj = new ReflectionClass($class_name); $obj_ins = $reflection_obj->newInstanceArgs($get_args); PHP Code:
|
| All times are GMT. The time now is 09:21 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0