mark_nsx Posted November 22, 2006 Share Posted November 22, 2006 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 intothe 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 processis 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 More sharing options...
bqallover Posted November 22, 2006 Share Posted November 22, 2006 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. Link to comment https://forums.phpfreaks.com/topic/28066-storing-_session-array-in-mysql-db/#findComment-128444 Share on other sites More sharing options...
Jenk Posted November 22, 2006 Share Posted November 22, 2006 If you are storing the session array in the database, it's better to just make a session handler that directly utilises the db. See here for an example:http://phpsecurity.org/code/ch08-2 Link to comment https://forums.phpfreaks.com/topic/28066-storing-_session-array-in-mysql-db/#findComment-128447 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.