pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richmond Dyes <rdyes@monroehosp.org>
To: pgsql-php@postgresql.org
Subject: Having problems with user defined sessions using postgresql as my session manager
Date: Thu, 14 Sep 2006 09:52:49 -0400
Message-ID: <45095EB1.50707@monroehosp.org> (raw)

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
I have written user defined session management library in php using
postgresql as my session repository.&nbsp; When I let my session timeout on
my browser I get the below errors on my screen.<br>
<br>
&nbsp;&nbsp; <b>Warning</b>: pg_query(): Query failed: ERROR: duplicate key
violates unique constraint "li_session_pkey" in <b>/var/www/html/liberty/includes/session.php</b>
on line <b>31</b><br>
<br>
<b>Fatal error</b>: Call to undefined function: pg_error() in <b>/var/www/html/liberty/includes/session.php</b>
on line <b>31</b><br>
<br>
<b>Warning</b>: Unknown(): A session is active. You cannot change the
session module's ini settings at this time. in <b>Unknown</b> on line <b>0<br>
<br>
The problem is in the write function of my library. Here it is:<br>
<br>
function pg_session_write($sid, $val) {<br>
&nbsp;&nbsp;&nbsp; $life = get_cfg_var("session.gc_maxlifetime");<br>
&nbsp;&nbsp;&nbsp; $exp = time() + $life;<br>
&nbsp;&nbsp;&nbsp; $selQ = "SELECT sidid FROM li_session<br>
&nbsp;&nbsp;&nbsp; WHERE sidid = '$sid' AND exptime &gt;". time();<br>
&nbsp;&nbsp;&nbsp; $selR= pg_query($selQ)or die("It didn't work:". pg_error());<br>
&nbsp;&nbsp;&nbsp; &nbsp;if(pg_num_rows($selR)) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $sesupQ ="UPDATE li_session SET<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exptime = '$exp', vidval = '$val'<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; WHERE<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sidid = '$sid' and exptime &gt;". time();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $sesupR=pg_query($sesupQ) or die("It didn't work:". pg_error());<br>
&nbsp;&nbsp;&nbsp; } else {<br>
&nbsp;&nbsp;&nbsp; &nbsp;$sesinQ = "INSERT INTO li_session<br>
&nbsp;&nbsp;&nbsp; VALUES('$sid', '$val', '$exp')";<br>
&nbsp;&nbsp;&nbsp; $sesinR= pg_query($sesinQ) or die("It didn't work:".
pg_error());&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; }<br>
}<br>
</b>
</body>
</html>




view thread (2+ messages)  latest in thread

Message-ID: <45095EB1.50707@monroehosp.org>
Permalink:  ../45095EB1.50707@monroehosp.org/
Also on:    postgresql.org/message-id/45095EB1.50707@monroehosp.org

 · 

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: rdyes@monroehosp.org
  Subject: Re: Having problems with user defined sessions using postgresql as my session manager
  In-Reply-To: <45095EB1.50707@monroehosp.org>
  References: <45095EB1.50707@monroehosp.org>

* 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