[Typo3-dev] Session ID generation

Kraft Bernhard kraftb at mokka.at
Mon Jan 24 18:54:06 CET 2005


Volker Hielscher wrote:
> i looked in the typo3.7 sourcecode for the session-id generation code:
> $id = substr(md5(uniqid('')),0,$this->hash_length); // New random 
> session-$id is made

As much as I know you wont have problems when the the uniqid function is
called in the same millisecond on both hosts ... because the hostid is taken
into account somehow ... i think I have read that in the uniqid php function
manual.

But I thought what would happen when the processor has two task running each
approaching the uniquid function. one task stops immedieatly before the uniquid
function because his process running time has timed out. another thread runns
until it executes the uniqid function an then switche again to the other thread/process
it will then execute the uniqid immediately after the previous one. pherhaps this
is no problem at the moment because thread/task switching takes longer than a
millisecond ... but pherhaps future processors get faster so i thought it would
be clever to have the process id in account.

I did something like:
$id = md5(uniqid('').getmypid());

the getmypid function is available since php3 ...


greets,
Bernhard
-- 
----------------------------------------------------------------------
"Freiheit ist immer auch die Freiheit des Andersdenkenden"
Rosa Luxemburg, 1871 - 1919
----------------------------------------------------------------------




More information about the TYPO3-dev mailing list