Jump to content

storing $_SESSION array in mysql db


mark_nsx

Recommended Posts

Hi there!

Im developing a shopping cart application with an option to save your carts.
I have kept a session array (i.e. $_SESSION['itemsInCart'][]) to store product_ID's into
(i.e. array_push($_SESSION['itemsInCart'], $product_ID);). Prior to storing this array into
the DB (in a MEDIUMBLOB row), i serialize() it, and for retrieval, i unserialize() it. Im getting weird results when I do a print_r() on the retrieved array at the moment..

I must've chosen the wrong data type for the row in which I store the array..or the entire process
is shot.. Thanks for all your help! Cheers!













Link to comment
https://forums.phpfreaks.com/topic/28066-storing-_session-array-in-mysql-db/
Share on other sites

From looking at the [url=http://uk.php.net/manual/en/function.serialize.php]serialize[/url] function at the php.net, it would seem there are a few peculiarities with regard to DB storage.  You might want to have a look at the comments, starting at the bottom of the page and working up.

I'm no expert on serialize(), but it says it returns a string so maybe storing as a VARCHAR might help?  Maybe not. :)  Your problem might be related to any one of the concerns raised on the above page, so I'd start there. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.