Skip site navigation (1) Skip section navigation (2)

Re: db connections in session variables

From: Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar>
To: pgsql-php(at)postgresql(dot)org
Subject: Re: db connections in session variables
Date: 2001-11-13 21:49:41
Message-ID: (view raw or whole thread)
Lists: pgsql-php
On Mar 13 Nov 2001 17:36, you wrote:
> I was wondering if it were possible to store a database connection in a
> session variable.

No! Because the persistent connection gets opened with one child, and when 
you go for the next page you have very high probabilities (unless you have a 
very poor http configuration) of caching a new child, and not the old one.

The problem comes here, just because the pconnect was done against the old 
child, and the new one doesn't know a thing about the pconnect you did 
before, so you'll allways (or almost always) an error of "wrong connection 

Hope I was clear.

> I have tried these 2 methods:
> $conn = pg_pconnect("server", "5432", "db");
> session_start();
> session_register('conn');
> $conn = pg_pconnect("server", "5432", "db");
> session_id($conn);
> session_start();
> both of them register a session with the value of "Resource id #1" but
> don't act as a db connection.  I am just trying to clean up some code so I
> don't have to do a new database connection on every page that I create.
> Then if you are able to do this, where would you close the connection?
> I guess in ASP, it is possible to store db connections in a session
> variable.  I have never done it there either but someone told me that you
> can.
> Tim.
> Timothy P. Maguire
> Web Developer II
> Harte-Hanks
> 978 436 3325
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?

Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
Martín Marqués                  |        mmarques(at)unl(dot)edu(dot)ar
Programador, Administrador, DBA |       Centro de Telematica
                       Universidad Nacional
                            del Litoral

In response to


pgsql-php by date

Next:From: Papp GyozoDate: 2001-11-14 09:53:49
Subject: Re: db connections in session variables
Previous:From: Timothy_MaguireDate: 2001-11-13 20:36:59
Subject: db connections in session variables

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group