Michael Gale wrote:

I am designing a web that will require access
> to a specific database. I am also using sessions and
> am storing the session data in the database.

So on every page that loads there will be a connection
> to the mysql server (local) to access the session db and
> tables and the web app database and tables.

My question is this would make two db connections per page
> right ? one after another ? -- which would not be optimized

Would it be better to but the session tables in with the web app tables under a common database ?? At first I thought that it would be more secure if the two where separate.

So long as you don't close the connection after you get your session data, the next call to mysql_connect() with the same parameters will realize there's already a connection open and use that.

Why not have a single include file that connects to your database, though? Then include your custom session hanlder which selects its database and retrieves the data. Then your main script selects it's database and does what it needs to do. Still one connection with less confusion.

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to