Welcome Guest, Not a member yet? Register   Sign In
Problem in Phpsession library
#1

[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
#2

[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




Theme © iAndrew 2016 - Forum software by © MyBB