...

View Full Version : Can I use $_SESSION to Store Objects?



dealmaker
01-09-2006, 07:36 PM
Hi,
Can I use $_SESSION to store objects?
e.g.
var $obj = new myclass();
$_SESSION['obj'] = $obj;

Many thanks.

marek_mar
01-09-2006, 07:38 PM
You can serialize objects with serialize() (http://www.php.net/serialize) and store the output of that function.

devinemke
01-09-2006, 07:39 PM
yes, but you need to call the class definition(s) prior to calling session_start (http://www.php.net/session_start). for this reason you cannot have session.auto_start ON in your php.ini.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum