Database connection info in cookies

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
vic128
Forum Newbie
Posts: 1
Joined: Sat Dec 18, 2004 3:01 am

Database connection info in cookies

Post 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
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Give it a go and see what happens.

Then try using mysql_pconnect() and see what happens.
Post Reply