CodeIgniter Forums

Full Version: MySQL Session Data Changes in CI V3
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

In CI V2 user session data was stored in MySQL as a TEXT type that was encoded by PHP's serialize().

In CI V3 user session data is now stored in MySQL as a BLOB type and the data is encoded in a
serialize()-like manner, but isn't quite serialize() data. Here is an example:

Code:
__ci_last_regenerate|i:1426712200;user_id|s:1:"1";user_email|s:22:"[email protected]";user_admin|i:1;user_auth|b:1;

I'm trying to connect to MySQL directly, read in that data, and convert it back into PHP values. Any suggestions for how I can parse this data in CI V3? I've tried to hunt down how CI is encoding this data, but can't seem to find it in the library.

Any help would be greatly appreciated.

Note: I know it sounds crazy that I am trying to read in and parse session data directly but I assure you it's for a good reason.
The session library uses PHP's native session handling (via session_set_save_handler()), so the method used to serialize the data is most likely based on your server's configuration: http://php.net/manual/en/session.configu...ze-handler
(03-19-2015, 09:35 AM)HelloHow  can i convert this code into array? aaron33 Wrote: [ -> ]Hello,

In CI V2 user session data was stored in MySQL as a TEXT type that was encoded by PHP's serialize().

In CI V3 user session data is now stored in MySQL as a BLOB type and the data is encoded in a
serialize()-like manner, but isn't quite serialize() data. Here is an example:


Code:
__ci_last_regenerate|i:1426712200;user_id|s:1:"1";user_email|s:22:"[email protected]";user_admin|i:1;user_auth|b:1;

I'm trying to connect to MySQL directly, read in that data, and convert it back into PHP values. Any suggestions for how I can parse this data in CI V3? I've tried to hunt down how CI is encoding this data, but can't seem to find it in the library.

Any help would be greatly appreciated.

Note: I know it sounds crazy that I am trying to read in and parse session data directly but I assure you it's for a good reason.
CodeIgniter session doesn't call any form of serialize or unserialize directly, but, as pointed out by mwhitney, rely on PHP's session.serialize_handler instead. Perhaps you are running up against different php.ini configs and/or PHP versions.