Custom PHP Session ID Generator

Posted on 2009-04-26
Last Modified: 2013-11-16

Could anyone please tell me whether it is possible to create a custom algorithm for generating the PHP SessionID? The rational behind the query is that the number of concurrent users of my application has increased considerably and I doubt whether the session ids generated by PHP overlap across distinct sessions.

Thanks in advance!
Question by:gtsupport
    LVL 4

    Accepted Solution

    Create Unique SessionId in PHP:


    Destroy Unique SessionId in PHP:

          $_SESSION = array();

    or you could try something like this:-

    md5(uniqid(microtime()) . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']);
    LVL 1

    Author Comment

    Thanks "dirtysnipe" for the input.

    So, would it be like

    session_id(md5(uniqid(microtime()) . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']));

    Or is there another way to initialize the session using a custom-generated session id?
    LVL 4

    Assisted Solution

    Looks about right.
    LVL 4

    Assisted Solution

    Heres a link to some usefull resources.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! How to Know You are Making a Difference at EE In August, 2013, one …
    Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
    This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now