Page 1 of 1

Can random numbers be predicted based on microtime?

Posted: Sun Jan 21, 2007 6:21 am
by WaldoMonster
Can random numbers be predicted based on microtime?
I ask this because I want to create a session id where the first part is based on microtime.
And the rest is filled up with random characters.
This way I'm 100% shore that never a same session id can be created.

Posted: Sun Jan 21, 2007 8:02 am
by feyd
Given the same algorithm use on all results, yes.

Why not use the built-in creation?

So long as the ID is uniform in length there is always the chance of a collision with a previous value. The chances grow smaller and smaller as the permutations grow. However, if it is flawed, mathematically your collision chances go up quickly as does the ability to guess ID's.

Posted: Sun Jan 21, 2007 2:20 pm
by WaldoMonster
feyd wrote:Given the same algorithm use on all results, yes.
Ok.
feyd wrote:Why not use the built-in creation?
I use a database/cookie session, so that I need to create my own id.
Or did you mean uniqid?
feyd wrote:So long as the ID is uniform in length there is always the chance of a collision with a previous value. The chances grow smaller and smaller as the permutations grow. However, if it is flawed, mathematically your collision chances go up quickly as does the ability to guess ID's.
Thanks for the info.

Posted: Sun Jan 21, 2007 2:55 pm
by feyd
Building your own session manager does not require you to create your own session ID's.

Take a look here: session_set_save_handler()