CodeIgniter Forums
Session library and unserialize() error. - 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: Session library and unserialize() error. (/showthread.php?tid=38407)

Pages: 1 2 3


Session library and unserialize() error. - El Forum - 06-17-2011

[eluser]ChimpWorks[/eluser]
[quote author="Twisted1919" date="1297463407"]Thank you for the resource, it was helpful.
I edited the _serialize() method :
Code:
function _serialize($data)
    {
        if (is_array($data))
        {
            foreach ($data as $key => $val)
            {
                if (is_string($val))
                {
                    $data[$key] = trim(str_replace('\\', '{{slash}}', $val));
                }
            }
        }
        else
        {
            if (is_string($data))
            {
                $data = trim(str_replace('\\', '{{slash}}', $data));
            }
        }

        return trim(serialize($data));
    }
I'll wait to see if there are improvements and i'll let u know of my findings .[/quote]

Did that work for you?


Session library and unserialize() error. - El Forum - 06-17-2011

[eluser]InsiteFX[/eluser]
Because the Reactor Team changed the field length on the user_agent but it is not documented in the User Guide! Look at the Session Class and you will see it! If the user_agent like IE goe's over the 50 chars it will not read the cookie!

InsiteFX


Session library and unserialize() error. - El Forum - 06-17-2011

[eluser]ChimpWorks[/eluser]
[quote author="InsiteFX" date="1308329033"]Because the Reactor Team changed the field length on the user_agent but it is not documented in the User Guide! Look at the Session Class and you will see it! If the user_agent like IE goe's over the 50 chars it will not read the cookie!

InsiteFX[/quote]

I am looking in the Session class from Reactor 2.0.2 and in the function sess_create() on line 319 the user_agent gets truncated to 50 chars then the data gets written to the database, so my point is it doesn't matter if you increase the varchar limit, there will only ever be 50 chars written. Please tell me if I'm missing something?


Session library and unserialize() error. - El Forum - 06-17-2011

[eluser]InsiteFX[/eluser]
Code:
$this->userdata = array(
    'session_id'    => md5(uniqid($sessid, TRUE)),
    'ip_address'    => $this->CI->input->ip_address(),
    'user_agent'    => substr($this->CI->input->user_agent(), 0, 120), // <-- See!
    'last_activity' => $this->now
);



Session library and unserialize() error. - El Forum - 06-17-2011

[eluser]ChimpWorks[/eluser]
So your suggesting changing it from 50 to 120? but what about user agents longer than 120 there are many?

http://stackoverflow.com/questions/654921/how-big-can-a-user-agent-string-get


Session library and unserialize() error. - El Forum - 06-17-2011

[eluser]bubbafoley[/eluser]
I'm pretty sure the change to the ua string length was done after 2.0.2 and so technically isn't released yet.

https://bitbucket.org/ellislab/codeigniter-reactor/changeset/e3c9990d33bc

2.0.2 Session.php: https://bitbucket.org/ellislab/codeigniter-reactor/src/521076012037/system/libraries/Session.php#cl-319


Session library and unserialize() error. - El Forum - 06-17-2011

[eluser]ChimpWorks[/eluser]
[quote author="bubbafoley" date="1308339907"]I'm pretty sure the change to the ua string length was done after 2.0.2 and so technically isn't released yet.

https://bitbucket.org/ellislab/codeigniter-reactor/changeset/e3c9990d33bc

2.0.2 Session.php: https://bitbucket.org/ellislab/codeigniter-reactor/src/521076012037/system/libraries/Session.php#cl-319[/quote]

Thank you for the clarification.

Made the changes so fingers crossed it stops the errors.


Session library and unserialize() error. - El Forum - 06-17-2011

[eluser]InsiteFX[/eluser]
Nope! It was done in 2.0.1

Search the forums an you will see all kinds of problems it caused to sessions.

InsiteFX


Session library and unserialize() error. - El Forum - 06-23-2011

[eluser]ChimpWorks[/eluser]
I'm still getting these errors:-

ERROR - 2011-06-23 00:09:29 --&gt; Severity: Notice --&gt; unserialize() [<a href='function.unserialize'>function.unserialize</a>]: Error at offset 81 of 96 bytes /home/l/i/livesite/web/system/libraries/Session.php 714

even after changing the user_agent field to varchar 120. I tend to agree with this post that its bots that are causing the errors...

http://ellislab.com/forums/viewthread/134524/#687483


Session library and unserialize() error. - El Forum - 08-25-2012

[eluser]bill19[/eluser]
I got a similar error caused by

Code:
error_reporting(E_ALL | E_STRICT);

when I commented it out, the error went away.

Bill