PostreSQL: passing a connection resource

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
Thanks for taking the time to read this.

I'm new to PHP, PostgreSQL, and a host of other things as I try to convert an MS Access DB into a web-based application.

While working with PHP, I'm wondering if a connection resource, as is generated by pg_connect(), can be passed through structures like $_SESSION or maybe $_POST. I've not found information on this in the various books I'm reading. I'm trying to eliminate the need for another login when calling a new web page (and there are many that will be called).

Any thoughts or advice on the matter is appreciated.

Monty51
 
I'm wondering if a connection resource, as is generated by pg_connect(), can be passed through structures like $_SESSION or maybe $_POST

No you can't, PHP loads up, executes your script then closes. This means that your pg_connect() closes and becomes redundant.

When a request comes from a users browser, a token is used to populate the $_SESSION variable, so whilst the information is stored on the server, you cannot easily access it without the correct token which is stored on the users browser either as a cookie or in the URL if cookies are disallowed by them. $_POST is sent from the browser and contains any information stored in a form, providing the user submits the form.

In other words, you will need to create a secure connection to your database on each and every visit from a user.
 
Back
Top