how do i keep a global instance of a database connection?
i am creating an admin site where a form calls, checklogin.php to validate the form fields with the database. it here that i send it off to the admin.php page if everything was successful. from admin.php, I want to access the same database connection/variable.
in checklogin.php i simply have this (stripped-down version of my code)
include('../objects/db.inc');
$db = new db();
after the form is validated, i send the user over to launchAdminWebsite.php which includes 3 php files, header.php, admin.php and footer.php. From the admin.php page, I want to be able to access that $db variable again.
I tried adding the $db to my session variables but that didn't work.
I tried the serialization trick found here: http://ca2.php.net/manual/en/language.oop5.serialization.php, but that didn't work either.
so what's the best way of doing this?