Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 931
  • Last Modified:

Custom PHP Session ID Generator

Hi

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!
0
gtsupport
Asked:
gtsupport
  • 3
3 Solutions
 
dirtysnipeCommented:
Create Unique SessionId in PHP:

      session_start();
      session_regenerate_id();

Destroy Unique SessionId in PHP:

      session_unset();  
      session_destroy();
      $_SESSION = array();


or you could try something like this:-

md5(uniqid(microtime()) . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']);
0
 
gtsupportAuthor Commented:
Thanks "dirtysnipe" for the input.

So, would it be like

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

Or is there another way to initialize the session using a custom-generated session id?
0
 
dirtysnipeCommented:
Looks about right.
0
 
dirtysnipeCommented:
Heres a link to some usefull resources.

http://uk2.php.net/manual/en/ref.session.php
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now