RE: [PHP-DB] Store $_SESSION in MySQL table

2005-02-11 Thread Bastien Koert
serialize the array before insertion and unserliaze it when you retreive it 
from the db

bastien
From: [EMAIL PROTECTED]
To: php-db@lists.php.net (PHP)
Subject: [PHP-DB] Store $_SESSION in MySQL table
Date: Fri, 11 Feb 2005 17:25:34 +
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


Re: [PHP-DB] Store $_SESSION in MySQL table

2005-02-11 Thread Martin Norland
[EMAIL PROTECTED] wrote:
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
.oO Advertising? ack! - Should I help him or not? :P
serialize() and base64encode() are your friend.
You can even create a class to store this information, if you wanted - 
so long as you have the class include()'d before you unserialize the 
object.  In all likelihood, however, you'll prefer just the straight 
$_SESSION.

Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php