CodeIgniter Forums

Full Version: Session Unserialize Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

ERROR - 2009-11-05 07:04:52 --&gt; Severity: Notice  --&gt; unserialize() [<a href='function.unserialize'>function.unserialize</a>]: Error at offset 176 of 176 bytes /system/libraries/Session.php 708

I often see this error coming by in the log files. Any ideas on what and how. My app seems to work fine but sometimes this error pops up in the log files. It seems to happen only with bots and not normal browsers but I'll have to double check this to be sure.

El Forum

[eluser]Chalda Pnuzig[/eluser]
I have the same problem!

ERROR - 2009-12-24 01:45:38 --&gt; Severity: Notice  --&gt; unserialize() [<a href='function.unserialize'>function.unserialize</a>]: Error at offset 101 of 112 bytes /privacy/system/libraries/Session.php 708

100 errors per day!!!

El Forum

I was having the same problem, and it turned out to be an issue with mbstring breaking the Encrypt library. I found a solution (and talked about my problem) in this post:

<a href=""></a>

El Forum

I have the same problem too

but I think this caused by the php configuration
I will try to set more memory for the php and check this and if success I will be back to tell you

El Forum

The problem may also appear when you're using UTF-8 and the ci_sessions table has incorrect charset (ex. latin1) set.

El Forum

It can also happen if you are only using cookies for storing session data and the (serialized) data exceeds the 4k max that cookies can store. It breaks the serialized array being stored as the string gets truncated, so it can't unserialize it.

El Forum

This had me foxed for a while.

I was getting this error on mobile only and only when using cellular.

I tried everything here

* mb_string fix
* change ci_sessions to UTF-8
* change ci_sessions.user_data to LONGTEXT

nothing worked.

I went back to basics and broke out the Chrome Dev Console and spotted the issue.

As my app runs through I was blindly executing a whole load of $this->session->set_userdata("bob", "value");

On entry to my app I was clearing these just in case they were still set. That led to 17 $this-?session->unset_userdata("bob") calls.

What I hadn't realised is that every one of these was adding a new header line with the cookie in it. Repeated over and over.

When this was being relayed over 3G their gateways were baulking over it and corrupting the headers by truncating them.

This caused the unserialise to fail. I reduced my calls to set_session and unset_sessions and doing all the work in one go and my problem vanished.

Hope this helps.

A very truncated extract from and HTTP request is below. The set-cookie was repeated for every set_userdata / unset_userdata I called.


HTTP/1.1 200 OK
Date: Sat, 06 Jul 2013 00:00:10 GMT
Server: Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
X-Powered-By: PHP/5.3.8
Set-Cookie: ci_session=q/Vn/OHstQ47IJ+ymFQCcIHYWWNE+5snApuE9ohLSAwJmSIdcvusdbNZClkS7/L7fSNRRV9Rded9R2jhIECrVPK5RyMdOqvoF+zxKLdfj8TxsMhB8cbA0h10xVnXyhBoQR+kLyQufqCLRJ9854QuT21JVPXCXX+AVKoIIcKaBA3R6x7T2b496lRrY+Micu+9A9GOxkJCYyDRJONFbgUtdBYAcMNWAjgMQpgrOGbM3RF8gG9UQfvclZAjs2VGJLGaH62GMGRrBvJxd9Grpt4XFB4NyV94KwpuF1LMmgyp7DRKSX+sc52t6a+90fJm2Nw+1i9lLUqxqtafDM2rafK45uCdVIDdMe0TB9vfCiCiAlbbalVheHHSmiCXywoAeeEstSH2T98TfNAmc39SCevULzorfL87P+2yCHliIKAyE6c=; expires=Sat, 06-Jul-2013 02:00:10 GMT; path=/
Set-Cookie: ci_session=XpFmcBfUCH4ieDFE0hEHftu6r/6eBdZuJtw1NTwBDkuGHXWIkgxppa05fp7E0uWl4iTWtDJqCxekQLxzvgzn49bCT9FOo7UHd2MDqEKX4Z3s3xa+0PPKSZ3F5VWVOBeTjHGJ4pqeSjw0wD2QCThqjrznwpEspJW1+AMf4Z2Ezq2RFTrQv8qysAQ+fnBBdqQ5T+cAEFkRcke+HLTuuoqX64nPEc5Da6jL541RcuX2LKe/DPBkKWPqTs8Js9ZmjXLxVkYMRXdB/ee6EW/CY8LqxibqjoWn+vyLjWN6VTxI5bh3NbMN1KVNPk7X9dWb9lf219o2cieShvWnxd5hDM++2/TIxSfrrc28zxIK7GyrQaO2dn7FuGUP1/ZGVVSIHiGSENg/tELM+/e8U2zngYze9WFbDfG6PEaayS/CT8GUIb8=; expires=Sat, 06-Jul-2013 02:00:10 GMT; path=/
Set-Cookie: ci_session=CzLPWQWj8/i7e1hu7eGeB3GTMoYdqAdSbwLdNj9oXg+DiMQHS0AhpFDof4ULz+EzsEJitwn/NsvSJTDC30MZq4sXHiSAiOfxg0ilRpiSJjLrPDTPYKAshOjYJ48JVlwqwKyLLhOKSJtAg4vCQuM4RWYRB0a+6p5YftLX+Sfnthg93rQ9ZCUWyNfC5OceNeJJz2SNJid9CT7FgIHZZzPtrUbGYrC8qnFmr5sklU/StaXtncSeM37zCAiwMj9VT2yrPPGcINMdeYx+amwv0AGVzfF5qIZgwmmVD9ENYPDdXJpZWz1mb6L1QkXxMrAx1QdT1t4HqeIiJzILyhWpCvWjKFwhro0XdHRekz+Bo/1HPdc+8JbLDzjK+/eRL0O6mBl9btNj27rG3OBAiGZPjnch8QTsyflcW0B/mSynVLxr/2o=; expires=Sat, 06-Jul-2013 02:00:10 GMT; path=/
Set-Cookie: ci_session=QoX31aooBbRRvymKmq+TiiO4Hq+tu61aAwa05/oZaMl2wBxrDHInkgugHnqSk20CGbA4M+MUoSttXoNCOIxsdo1Qvlo2NZbvmzw0iHBpFLyxAXdMOGlqPHIYbUsENNRAIYLekj5am8wxPRhzbAK0G3kF/C6YH4APDDUTB1QE9vtxmzAyiol/REmLWGjyWtOlmobZvIe2lw2qPrzhaLFbk7xZHc+9waCVva1Za/+LOd7nR5LEDu8LytYtpqWugeYfgGJG5NHDRJ3+xEJs5LzfnsegP64Oc1nWVLZRbiX2qWT/3sz4ll39nlPFiD+cpdFsMnBdeUroH7Dy460H2Efrxylq4Tus/dlgqop9JDdX8wxhbzyqKOxdaH9MHDdgZiQ7qNgeruFaXHm8PCKk4PS8NQ+qVTp/4g4SR3qj2m+sl9Q=; expires=Sat, 06-Jul-2013 02:00:10 GMT; path=/