More Session Handler Issues
Posted: Tue May 11, 2010 9:54 am
Hey,
I'm currently building a session handler class which not only shoves session data into a mysql database but also ties relevant sessions to a users table. I figured, since sessions and user authentication are so interlinked, that I should power both with the session_set_save_handler functions.
A problem I'm having, is tweaking the session_data that is generated by PHP's session engine. How can I decode this data and use just one or two of the contained assoc arrays contained within it, in order to update a few fields on a completely different database table?
An assoc array like this:
$_SESSION['cart'] = "this is my cart";
looks like this in the database:
cart|s:15:"this is my cart";
But how can I turn it back into an assoc array which PHP can understand so it can pump a specific key/value from the assoc array into my users table?
Just to be clear, I have managed to get the session data back out of the database and into the $_SESSION super-global working nicely. But I don't want to have to wait for the super-global to become re-populated before updating my users table. Hence, I want to pick out some data from the session data before it gets sent back to the $_SESSION super-global. I've tried session_decode() with no avail.
Cheers,
drayfuss
I'm currently building a session handler class which not only shoves session data into a mysql database but also ties relevant sessions to a users table. I figured, since sessions and user authentication are so interlinked, that I should power both with the session_set_save_handler functions.
A problem I'm having, is tweaking the session_data that is generated by PHP's session engine. How can I decode this data and use just one or two of the contained assoc arrays contained within it, in order to update a few fields on a completely different database table?
An assoc array like this:
$_SESSION['cart'] = "this is my cart";
looks like this in the database:
cart|s:15:"this is my cart";
But how can I turn it back into an assoc array which PHP can understand so it can pump a specific key/value from the assoc array into my users table?
Just to be clear, I have managed to get the session data back out of the database and into the $_SESSION super-global working nicely. But I don't want to have to wait for the super-global to become re-populated before updating my users table. Hence, I want to pick out some data from the session data before it gets sent back to the $_SESSION super-global. I've tried session_decode() with no avail.
Cheers,
drayfuss