You are here: Re: [PHP] using require « PHP « IT news, forums, messages
Re: [PHP] using require

Posted by Jochem Maas on 10/18/98 11:19

Cima wrote:
> hi all,
>
>
> i have my web site working something like this: in every php script i have require(auth.php). this auth.php has my connection to my postgresql server and database along with some other stuff i need for the user to be authenticated to my web site. when i log on, this auth.php connects to the dbserver and checks if my username and password are stored and then i go to a home page. my connection is stored in $dbh.
> what happens when i start moving through all these web pages (php scripts), each requires auth.php, with respect to the connection? is a new connection established for every web page i go into that uses my $dbh for querying purposes or is it the same connection i originally made when i first logged into the web site?

<aside>wtf happened to the wordwrap?! :-)</aside>

I can assume that you use the session, or whatever, to track someones 'logged in' status?

And that you only check the credentials against the values in the DB when someone
actually submits a login form?

Then there is no reason as such to create the DB connection on every request,
although you should consider that you may be connecting to the DB for other
data than just login credentials regardless of 'logged in' status.

Are you using a *_connect() function or a *_pconnect() function?
*_pconnect() creates a persistent connection (assuming your setup allows
it) - though there is no garantee that a request will use the same connection,
because there is no garantee that a specific webserver process/thread will
handle a given http request - each webserver process/thread (normally?) has
its own persistent connection to the DB.

>
>
> any info will be highly appreciated!!
>

show us auth.php, if you can/may.
also try:

var_dump($dbh);

....in code to see what it contains on each request.

rgds,
Jochem

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация