db connections in session variables

From: Timothy_Maguire(at)hartehanks(dot)com
To: pgsql-php(at)postgresql(dot)org
Subject: db connections in session variables
Date: 2001-11-13 20:36:59
Message-ID: OFD16A9778.5F12758D-ON85256B03.0066298C@hartehanks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

I was wondering if it were possible to store a database connection in a
session variable.

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

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Martín Marqués 2001-11-13 21:49:41 Re: db connections in session variables
Previous Message Haller Christoph 2001-11-13 09:35:24 Re: Joins!!