pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedHaving problems with user defined sessions using postgresql as my session manager
2+ messages / 2 participants
[nested] [flat]
* Having problems with user defined sessions using postgresql as my session manager
@ 2006-09-14 13:52 Richmond Dyes <rdyes@monroehosp.org>
0 siblings, 1 reply; 2+ messages in thread
From: Richmond Dyes @ 2006-09-14 13:52 UTC (permalink / raw)
To: pgsql-php
<!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. When I let my session timeout on
my browser I get the below errors on my screen.<br>
<br>
<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>
$life = get_cfg_var("session.gc_maxlifetime");<br>
$exp = time() + $life;<br>
$selQ = "SELECT sidid FROM li_session<br>
WHERE sidid = '$sid' AND exptime >". time();<br>
$selR= pg_query($selQ)or die("It didn't work:". pg_error());<br>
if(pg_num_rows($selR)) {<br>
$sesupQ ="UPDATE li_session SET<br>
exptime = '$exp', vidval = '$val'<br>
WHERE<br>
sidid = '$sid' and exptime >". time();<br>
$sesupR=pg_query($sesupQ) or die("It didn't work:". pg_error());<br>
} else {<br>
$sesinQ = "INSERT INTO li_session<br>
VALUES('$sid', '$val', '$exp')";<br>
$sesinR= pg_query($sesinQ) or die("It didn't work:".
pg_error()); <br>
}<br>
}<br>
</b>
</body>
</html>
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Having problems with user defined sessions using postgresql
@ 2006-09-14 15:10 Erik Jones <erik@myemma.com>
parent: Richmond Dyes <rdyes@monroehosp.org>
0 siblings, 0 replies; 2+ messages in thread
From: Erik Jones @ 2006-09-14 15:10 UTC (permalink / raw)
To: Richmond.Dyes@monroehosp.org; +Cc: 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@myemma.com>
software development
emma(r)
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2006-09-14 15:10 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-09-14 13:52 Having problems with user defined sessions using postgresql as my session manager Richmond Dyes <rdyes@monroehosp.org>
2006-09-14 15:10 ` Re: Having problems with user defined sessions using postgresql Erik Jones <erik@myemma.com>
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