SEO-Board: Free, Fast and Search Engine Optimization Friendly Forum Script
»User: »Password:   Remember Me? 
SEO-Board Forum Software Community / General / Programming / fatal error - @unserializing cookie gives no output
Posted:  25 Sep 2011 20:53   Last Edited By: Roel B
I'm using SEO-Board 1.1.0
All of a sudden, after having used SEO-Board for two years, it gives a fatal error when you already have a cookie.
The fatal error is produced by this part of the index.php file (in the root of the forum):
Code:

if (isset($_COOKIE[$cookiename]))
{
  list($user_id, $user_pass_sha1) = @unserialize(stripslashes($_COOKIE[$cookiename])); 
  $user_id = addslashes($user_id);
  $user_pass_sha1 = addslashes($user_pass_sha1);

  if (!is_numeric($user_id))
    die($lang['fatal_error']);

By adding a test line of code, I can see that there is a cookie and it produces a long string with characters, but the @unserialize produces nothing (both $user_id and $user_pass_sha1 are empty).
Any suggestions?

Regards,
Roel
Posted:  25 Sep 2011 21:26   Last Edited By: Roel B
For testing (to allow error reporting) I removed the @ which is just in front of "unserialize and then I get the following message:
Quote:
Notice: unserialize() [function.unserialize]: Error at offset 9 of 74 bytes in /home/www/luxsoft.eu/forum/index.php on line 82


If I delete my cookie in the browser I get no error. However, if I then register and click login I get the same fatal error again.
Roel
Posted:  25 Sep 2011 21:59
What's your php version? Have you changed anything in the code recently?
Posted:  25 Sep 2011 22:12   Last Edited By: Roel B
Thanks Hristo for the fast response!

I'm using PHP 5.3

I've done some further testing and saw that at 3 place there were 3 backslashes (\\\) in my cookie string.

So I replaced
@unserialize(stripslashes($_COOKIE[$cookiename]))
by
@unserialize(str_replace('\\','',($_COOKIE[$cookiename]))); //remove all backslashes
and now all works fine again.

Possible reason:
I made some changes to my php.ini file, related to error reporting. When the SEO-Board fatal error started occurring, I asked my ISP to restore the default php.ini settings. They said they did so, but I have the feeling it has still something to do with php.ini (maybe magic_quotes?)

I can live with my "str_replace" solution but I'm curious to know what went wrong.
Posted:  26 Sep 2011 07:34
Somehow the cookie string gets add-slashed twice (on login or in general). I have a php 5.3.5 here and test it.