Re: Having problems with user defined sessions using postgresql

From: Erik Jones <erik(at)myemma(dot)com>
To: Richmond(dot)Dyes(at)monroehosp(dot)org
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: Having problems with user defined sessions using postgresql
Date: 2006-09-14 15:10:43
Message-ID: 450970F3.1070507@myemma.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

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(at)myemma(dot)com>
software development
emma(r)

In response to

Browse pgsql-php by date

  From Date Subject
Next Message ben wilko 2006-10-03 04:08:07 Select Where using character varying ??
Previous Message Richmond Dyes 2006-09-14 13:52:49 Having problems with user defined sessions using postgresql as my session manager