Page 1 of 1

Database connection info in cookies

Posted: Sat Dec 18, 2004 3:12 am
by vic128
I'll keep it short:
Can I save database connection information in a cookie?

let's say I do

Code: Select all

<?php
$conn = mysql_connect("localhost","user","pwd");
setcookie("conn","$conn");

#then later, after the user fills out a form in the page, and submits it

if($_COOKIE['conn'] ) {
$conn = $_COOKIE(['conn'];
}
?>
Basically, I have a page, where the user will be doing several queries to one database and then come back to the same page, but I don't want to keep opening the database each time the page is called.
Sorry if this is too easy,
Victor

Posted: Sat Dec 18, 2004 3:41 am
by kettle_drum
Give it a go and see what happens.

Then try using mysql_pconnect() and see what happens.