CodeIgniter Forums
Problem in Phpsession library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Problem in Phpsession library (/showthread.php?tid=2172)



Problem in Phpsession library - El Forum - 07-19-2007

[eluser]Marcus Cavalcanti[/eluser]
I found a small bug in Phpsession library. When i save an object in session, when i retrieve this object it has the information: "object(__PHP_Incomplete_Class)"

To fix this problem, i modified the save() method of Phpsession class. The method fixed:

Code:
/* Save a session variable.
  * @paramstringName of variable to save
  * @parammixedValue to save
  * @paramstring  (optional) Namespace to use. Defaults to 'default'. 'flash' is reserved.
*/
function save($var, $val, $namespace = 'default') {
  if ($var == null) {
   if (is_object($val)) {
$_SESSION[$namespace] = (object) get_object_vars($val);
   } else {
$_SESSION[$namespace] = $val;
   }
  } else {
   if (is_object($val)) {
$_SESSION[$namespace][$var] = (object) get_object_vars($val);
   } else {
$_SESSION[$namespace][$var] = $val;
   }
  }
}

The cause of this problem is found there: http://www.thescripts.com/forum/threadedpost56014.html

Smile

Marcus Cavalcanti


Problem in Phpsession library - El Forum - 11-06-2008

[eluser]dootzky[/eluser]
I just had the same problem. Solution is either that you've described here, OR, you can just load your class (which should be in Libraries folder for convenience) just BEFORE session class, in autoload.php config file, like this:

$autoload['libraries'] = array('database', 'cart', 'session');

and that's it!
cheers,
dootzky