serialize the array before insertion and unserliaze it when you retreive it
from the db
bastien
From: veditio@xxxxxxxxxxx
To: php-db@xxxxxxxxxxxxx (PHP)
Subject: Store $_SESSION in MySQL table
Date: Fri, 11 Feb 2005 17:25:34 +0000
Greetings all.
While trying to create a session-based advertising model that does not rely
on the existence of cookies, I ran into trouble: I can't figure out how to
place the entire $_SESSION array into a MySQL table row, then retrieve it
and use the information from one page to the next.
The best that I can do is copy the PHPSESSID into a MySQL row, then dissect
the $_SESSION array so that each of its parts can be stored in a separate
row of the same record. Then, with the $_GET variable, I am able to get the
MySQL_last_id and retreive the information from the correct field, and it
works across pages.
The only problem is this: should the $_SESSION array grow with more
data--say, adding a first name variable, and a time-of-day varaible--then I
need to update the MySQL table whenever I do this. Not a big deal, I know,
but I'm frustrated with this.
One more thing: one of the variables in the $_SESSION array is an <img src>
url, so it screws up the mysql insert, even when I use serialize.
Thanks for any help you can give.
--V
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php