Announcement

Collapse
No announcement yet.

Best way to generate Random, Unique Session ID's

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Scott MacVicar
    replied
    Originally posted by Lorddraco98
    i'm working on building a user object for a website I'm working on. In the user object, userid and sessionid must be stored into a cookie and then sent to the user. The userid and sessionid along with info about the user(IP, username, etc) are inserted into a MySQL DB. I'm looking for a way to generate a random, unique sessionid that PHP can make, store in the DB, insert into that cookie, and can also use to look up a user in the DB. So what's the best way to generate a random, unique session ID with PHP??
    just try and shove as much random stuff into md5, i use the following

    PHP Code:
    md5(uniqid(microtime()) . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']); 

    Leave a comment:


  • Gamefreak
    replied
    use the function uniqid(val$)

    the val$ can be blank, but if you put something in there it will have that val$ in the id. After you do that, then put the result through md5(), it will give you good session ids.

    Leave a comment:


  • Lorddraco98
    started a topic Best way to generate Random, Unique Session ID's

    Best way to generate Random, Unique Session ID's

    i'm working on building a user object for a website I'm working on. In the user object, userid and sessionid must be stored into a cookie and then sent to the user. The userid and sessionid along with info about the user(IP, username, etc) are inserted into a MySQL DB. I'm looking for a way to generate a random, unique sessionid that PHP can make, store in the DB, insert into that cookie, and can also use to look up a user in the DB. So what's the best way to generate a random, unique session ID with PHP??
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X