in reply to Generate a session ID

Are you really sure you're never going to need more than a couple million sessions at a time? There are only just over four million possible combinations of eight hex digits, and if you're picking at random and checking for collisions you do not want to get anywhere near exhausting the space.

If sessions expire after a few minutes, 16^8 is enough, assuming you're not one of the dozen top sites. I'd be careful about how long sessions last before they expire, though, and check that the collision detection allows expired sessions to be reused, or that something ensures they are deleted so as not to cause collisions.

Replies are listed 'Best First'.
Re^2: Generate a session ID
by Your Mother (Archbishop) on Dec 03, 2005 at 19:57 UTC
    four million possible combinations of eight hex digits

    I think you meant billion, right? There are more than 4 million combinations of plain old integers in 8 digits. Though given BrowserUK's post, it's moot anyway. :)

    $ perl -e 'print 16 ** 8, $/' 4294967296
      Yeah, sorry, got my powers of 1000 crossed momentarily.