pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Erik Jones <erik@myemma.com>
To: Richmond.Dyes@monroehosp.org
Cc: pgsql-php@postgresql.org
Subject: Re: Having problems with user defined sessions using postgresql
Date: Thu, 14 Sep 2006 10:10:43 -0500
Message-ID: <450970F3.1070507@myemma.com> (raw)
In-Reply-To: <45095EB1.50707@monroehosp.org>
References: <45095EB1.50707@monroehosp.org>

Ok,

1.  PHPs postgres lib doesn't have a pg_error() function.  You want 
pg_last_error().
2.  Are you using the sid as li_session's primary key?  If so, before 
you create a new session with an already existing sid, you will need to 
delete the old sid entry before inserting a new one with the same sid.

Richmond Dyes wrote:
> I have written user defined session management library in php using 
> postgresql as my session repository.  When I let my session timeout on 
> my browser I get the below errors on my screen.
>
>    *Warning*: pg_query(): Query failed: ERROR: duplicate key violates 
> unique constraint "li_session_pkey" in 
> */var/www/html/liberty/includes/session.php* on line *31*
>
> *Fatal error*: Call to undefined function: pg_error() in 
> */var/www/html/liberty/includes/session.php* on line *31*
>
> *Warning*: Unknown(): A session is active. You cannot change the 
> session module's ini settings at this time. in *Unknown* on line *0
>
> The problem is in the write function of my library. Here it is:
>
> function pg_session_write($sid, $val) {
>     $life = get_cfg_var("session.gc_maxlifetime");
>     $exp = time() + $life;
>     $selQ = "SELECT sidid FROM li_session
>     WHERE sidid = '$sid' AND exptime >". time();
>     $selR= pg_query($selQ)or die("It didn't work:". pg_error());
>      if(pg_num_rows($selR)) {
>         $sesupQ ="UPDATE li_session SET
>         exptime = '$exp', vidval = '$val'
>         WHERE
>         sidid = '$sid' and exptime >". time();
>         $sesupR=pg_query($sesupQ) or die("It didn't work:". pg_error());
>     } else {
>      $sesinQ = "INSERT INTO li_session
>     VALUES('$sid', '$val', '$exp')";
>     $sesinR= pg_query($sesinQ) or die("It didn't work:". pg_error());   
>     }
> }
> * 


-- 
erik jones <erik@myemma.com>
software development
emma(r)




view thread (2+ messages)

Message-ID: <450970F3.1070507@myemma.com>
Permalink:  ../450970F3.1070507@myemma.com/
Also on:    postgresql.org/message-id/450970F3.1070507@myemma.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: erik@myemma.com, Richmond.Dyes@monroehosp.org
  Subject: Re: Having problems with user defined sessions using postgresql
  In-Reply-To: <450970F3.1070507@myemma.com>
  References: <45095EB1.50707@monroehosp.org> <450970F3.1070507@myemma.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox