Skip site navigation (1) Skip section navigation (2)

Having problems with user defined sessions using postgresql as my session manager

From: Richmond Dyes <rdyes(at)monroehosp(dot)org>
To: pgsql-php(at)postgresql(dot)org
Subject: Having problems with user defined sessions using postgresql as my session manager
Date: 2006-09-14 13:52:49
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-php
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<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>
&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>
<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>
<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>
The problem is in the write function of my library. Here it is:<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>

Attachment: unknown_filename
Description: text/html (2.1 KB)


pgsql-php by date

Next:From: Erik JonesDate: 2006-09-14 15:10:43
Subject: Re: Having problems with user defined sessions using postgresql
Previous:From: Nikolay SamokhvalovDate: 2006-09-07 09:13:17
Subject: Re: binary cursor returning truncated data

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group