Sessions + Connection Object?

From: Date: Fri, 03 Nov 2000 15:27:47 +0000
Subject: Sessions + Connection Object?
Groups: php.general 
Request: Send a blank email to php-general+get-23583@lists.php.net to get a copy of this message
Hi, I'm working on changing a site around that I am currently tinkering with as a learning experience. The site uses MySQL and PHP4. Currently, everytime I load a page and do a select from the database, it logs in and selects the database. I would like to be able to store the connection in a session and do something like: (code might not be perfect, but its as close as i can remember atm) if (!session_is_registered("db")) { echo "Created connection"; session_register("db"); // can ref as global now by $db $db = mysql_connect....; { else echo "Using Cached Connection"; this code is in a file called .htdb. in idex i refer to it like so: <?php require(".htdb"); require(".htheader"); ?> I know this type of thing can be done in ASP, has anyone done it in php? Thanks, ----------------------------------------------------------------------- | Daryl Chance | We start seeing these new accounts being created, | | -------------- | but that could be an anomaly of the system. After | | Valuedata, LLC | a day or two, we realized it was someone hacking | | Memphis, TN | into the system. - Microsoft on thier hacker | -----------------------------------------------------------------------

« previous php.general (#23583) next »