[nycphp-talk] Passing Objects Via Session in PHP 4
Phillip Powell
phillip.powell at adnet-sys.com
Mon Sep 27 14:09:43 EDT 2004
Dan Cech wrote:
> Joseph Crawford wrote:
>
>> the sessions seem to carry over now however my resource ID for my
>> $db->connection keep changing, i have even altered the open method to
>> look like this
>>
>> if(!$this->connection) {
>> $conn = mysql_connect($hostname, $username, $password);
>> if(!$conn) trigger_error(mysql_error(), E_USER_ERROR);
>> else $this->connection = $conn;
>> }
>>
>> any ideas how to keep that from getting a new resource handle but
>> rather use the same one?
>
>
> Ok,
>
> 1. You don't need to manually serialize stuff you put into the session
> through $_SESSION, php automatically serializes and unserializes the
> $_SESSION array for you.
Ok I'm sorry I have to ask this: Why is it specific to just $_SESSION
that it auto-serializes anything you put into it?
Phil
>
> 2. You cannot store a resource ID in a session. The resource ID is
> specific to that particular instance of the script, you will have to
> reopen the database connection for each request.
>
> If you use persistent database connections it *may* still use the same
> connection to the database, but the resource ID will be different.
>
> Dan
> _______________________________________________
> New York PHP Talk
> Supporting AMP Technology (Apache/MySQL/PHP)
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.newyorkphp.org
>
--
---------------------------------------------------------------------------------
Phil Powell
Multimedia Programmer
BPX Technologies, Inc.
#: (703) 709-7218 x107
Fax: (703) 709-7219
More information about the talk
mailing list