Page 1 of 1

create unique token!!!

Posted: Mon Nov 13, 2006 6:04 am
by jmut
is this unique enough?

Code: Select all

md5(uniqid(rand(), true));

Posted: Mon Nov 13, 2006 6:52 am
by volka
Isn't uniqid() unique enough? If not, the function failed its purpose.

With md5() you only gain the possibility of a collision, i.e. the same (and therefore not-so-unique) hash for different input data but no increase in "uniqueness" (as if it's possible anyway ;))

Posted: Mon Nov 13, 2006 7:33 am
by Jenk

Code: Select all

$new_token = $last_token + 1;
will get you a unique number.

Posted: Mon Nov 13, 2006 7:49 am
by jmut
Jenk wrote:

Code: Select all

$new_token = $last_token + 1;
will get you a unique number.
kind of don't want to create file just for that one. token should be unique for each requests.
I don't want to rely on DB...and if not..there are some concurency problems etc that will have to be solved.