Hi, everyone,
I need a reliable way to generate unique IDs for use with MySQL tables. I have written a summer camp registration page that allows users to register for a summer camp and then pay online by credit card.
I have several MySQL tables in which I store information about the registrant. One table stores the camper's personal information, one table stores his/her health records, etc. Another table stores the credit card transaction data (minus the card number and some other things).
I need a way to link these tables together (possibly using the JOIN command). The catch is that users do not have to create accounts with us to make purchases on the website (this was not my decision to make). Therefore, I cannot use a login name or ID as the primary key in these various tables. I also don't want to rely on auto_increment numbers as primary keys, because they may eventually be reset and not all tables have the same number of rows.
The way I am doing it now is with session IDs (the official ones generated by PHP, not some method I devised). I am ultimately wondering what are the chances of two users being assigned the same session ID within some reasonably short period (maybe one year?). Obviously this depends on how many users visit the site. Let's say that it's around 2,000 per month and every visitor is assigned a session ID.
Are PHP session IDs the most "random" string that PHP can generate? I'm not even sure I WANT random: I just want unique IDs that are unlikely to be the same over any short period of time (1 year?). I doubt PHP keeps track of the session IDs it's assigned between Apache restarts, right?
Thanks for your insights!