tags:

views:

163

answers:

2

Psudeocode or PHP code desirable. References even better on the components and procedures to generate the PHPSESSID manually.

+7  A: 

The code that generates the sssion ID is here - but it's C, since that's how PHP itself is implemented.

Basically, it uses a cryptographic hash function and as input the remote IP address, the current time and some other stuff.

The hash function to use and optionally a source of additional entropy can be configured in php.ini.

Michael Borgwardt
That is not C++, its C.
Tim Post
@Tim: Ah, right. I saw some -> in there and wasn't aware that C uses that operator as well.
Michael Borgwardt
+1 for correcting and indicating it can be salted in php.ini :)
Tim Post
+4  A: 

It's hashed from the remote address and the current time, in ext/session/session.c:344(php_session_create_id()).

Ignacio Vazquez-Abrams