On Tue, Jun 12, 2001 at 05:33:02PM +0100, Dan wrote:
> Hello,
> 
> I have a small php script to log web access that writes to a psql database.
> The error I get everytime I do a refresh is:
> Warning: PostgreSQL query failed: ERROR: Cannot insert a duplicate key into
> unique index session_pkey in /var/www/php/web.php on line 22
> 
> 
> As I understand it the session ID it adds is a primary key and therefore
> cannot be duplicated.
> Can I create another collumn that auto increments a number ( starting with 1
> will be fine ) that can be the primary key/index?
> Firstly is this the best way to do it, also can anyone point me to any
> webpages with rough newbie instructions on this?

sounds like you're setting session id properly, but then you're
trying to insert it into the database every single time, even if
it's a return visit. the logic should look something like
this--

        if not exists session-cookie
                create session-cookie/session-id
                insert session-data into database
        else
                get session-id from session-cookie
                get session-data from database
        endif
        ...

and it's good to have an extra field with a timestamp default, so
you can go through and reap your old sessions after a few weeks.

-- 
I figure: if a man's gonna gamble, may as well do it
without plowing.   -- Bama Dillert, "Some Came Running"

[EMAIL PROTECTED]
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to