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??

    $sid = md5(uniqid(rand(), str_replace(".","", $_SERVER['REMOTE_ADDR'])));
    
      25 days later

      Hello,

      Why would you not want php to generate a session id itself via the session_id() and session_start() functions?

      Ed

        Write a Reply...