The ID Session will the tables Primary Key. It uses the mysql_insert_id() function to return the Primary key of the record that was just inserted. It sounds like your tables are not using a primary key, even when using a composite key, it is a good idea to use a primary key also.