motorollin wrote:
Wouldn't increasing the length of the session ID decrease the likelihood of a "collision"? Personally I use a 128 character key as the session ID when I'm writing a web app.
--
moto
PHP itself uses a 128-bit session ID by default. Normally this should be fine, but the actual hashing algorithm itself is the problem. It just isn't as unique as first thought.
-edit-
According to the manual, PHP5 allows you to set the hash function and bits per character used for the session ID. This functionality is not available in PHP4 and I am not sure which version is used here.
Just setting session.hash_function in the php.ini to 1 would switch to SHA-1 which is a better hash function than MD5.
A second point to consider is that the database schema may also reference the session ID and expect them to be a particular type, which would complicate fixing things...
-/edit-
Your 128-character ID would be 1024-bit, assuming that every bit of the byte is used, or 512-bit if the string is a hex code. If the algorithm were poor, you could still get collisions a lot sooner than you expect.
Another thing to consider is that excessively long hashcodes take time to generate and lookup. If you have a lot of hits, you might find a fair amount of server time is spent just doing this one job ;-)
To put things in perspective, however, this is a busy site with >1000 users constantly coming and going. It has happened just this once (as far as we know) in the entire time since it has been open (spanning several years)