Welcome Guest, Not a member yet? Register   Sign In
Session Unserialize Error in Logs
#1

[eluser]Kyle Johnson[/eluser]
I'm running 2.1.0 on PHP Version 5.3.2-1ubuntu4.14 with MSSQL 2008 R2 as a backend.

Code:
Error
- 2012-03-05 14:34:14 --> Severity: Notice  --> unserialize(): Error at offset 0 of 1 bytes /var/www/system/libraries/Session.php 724

This error showed up whenever a user didn't have any session data associated with them, it disappeared when they logged in and had session data in the database.

I was able to fix this by modifying the Session.php file to trim the data:

OLD:
Code:
/**
  * Unserialize
  *
  * This function unserializes a data string, then converts any
  * temporary slash markers back to actual slashes
  *
  * @access private
  * @param array
  * @return string
  */
function _unserialize($data)
{
  $data = @unserialize(strip_slashes($data));

  if (is_array($data))
  {
   foreach ($data as $key => $val)
   {
    if (is_string($val))
    {
     $data[$key] = str_replace('{{slash}}', '\\', $val);
    }
   }

   return $data;
  }

  return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data;
}

NEW:
Code:
/**
  * Unserialize
  *
  * This function unserializes a data string, then converts any
  * temporary slash markers back to actual slashes
  *
  * @access private
  * @param array
  * @return string
  */
function _unserialize($data)
{
  $data = @unserialize(strip_slashes(trim($data)));

  if (is_array($data))
  {
   foreach ($data as $key => $val)
   {
    if (is_string($val))
    {
     $data[$key] = str_replace('{{slash}}', '\\', $val);
    }
   }

   return $data;
  }

  return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data;
}




Theme © iAndrew 2016 - Forum software by © MyBB