X-Original-To: pgsql-php-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 034009FA15C for ; Thu, 14 Sep 2006 10:53:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 31325-05 for ; Thu, 14 Sep 2006 10:52:47 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from emailserver.monroehosp.org (emailserver.monroehosp.org [199.248.251.5]) by postgresql.org (Postfix) with ESMTP id 35BFD9FA0C4 for ; Thu, 14 Sep 2006 10:52:55 -0300 (ADT) Received: from vams.monroehosp.org (unknown [172.31.5.102]) by emailserver.monroehosp.org (Postfix) with SMTP id 238AEBC6F for ; Thu, 14 Sep 2006 09:52:51 -0400 (EDT) Received: from [127.0.0.1] (unknown [199.248.251.30]) by emailserver.monroehosp.org (Postfix) with ESMTP id 98835BC6F for ; Thu, 14 Sep 2006 09:52:50 -0400 (EDT) Message-ID: <45095EB1.50707@monroehosp.org> Date: Thu, 14 Sep 2006 09:52:49 -0400 From: Richmond Dyes Reply-To: Richmond.Dyes@monroehosp.org Organization: Monroe Community Hospital(Director of Information Systems) User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: pgsql-php@postgresql.org Subject: Having problems with user defined sessions using postgresql as my session manager Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.383 tagged_above=0 required=5 tests=AWL, HTML_40_50, HTML_MESSAGE, HTML_TITLE_EMPTY, MIME_HTML_ONLY X-Spam-Level: X-Archive-Number: 200609/2 X-Sequence-Number: 3599 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());   
    }
}