Okay. To guarantee uniqueness, let's do two things: 

* Check if $_SERVER[REMOTE_ADDR] isset before referencing it
* Set a unique index on the key field in the session table, and on insert catch a PDOException that complains if another matching session ID is inserted. If so, regenerate and try again -- put this in a loop.

Thank you!