CodeIgniter Forums
MySQL Session Data Changes in CI V3 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: MySQL Session Data Changes in CI V3 (/showthread.php?tid=1541)



MySQL Session Data Changes in CI V3 - aaron33 - 03-19-2015

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.


RE: MySQL Session Data Changes in CI V3 - mwhitney - 03-20-2015

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.configuration.php#ini.session.serialize-handler


RE: MySQL Session Data Changes in CI V3 - nirav - 07-09-2015

(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.



RE: MySQL Session Data Changes in CI V3 - tegaphilip - 06-29-2018

Check my answer here

https://stackoverflow.com/a/51103875/1214244


RE: MySQL Session Data Changes in CI V3 - dave friend - 06-29-2018

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.