Forum Moderators: DixonJones

Message Too Old, No Replies

random user ids (php) problem

the same ids generated

         

Furmanov

4:25 pm on Jul 22, 2003 (gmt 0)

10+ Year Member



we use cookie to track unique visitors, actually we started doing less than a week ago

the code we use in the uid.php is

$charset='abcdef.... XYZ1234567890';
mt_srand((double)microtime()*1000000);
$x="";
for($i=1; $i<=16; $i++ ) $x.=$charset[mt_rand(0, 66)];

so, i think there is a really really really little probability opf the same UID (user id) generated twice for different users

the script assigns usid to crawler when they fetch the pages too

anyway, I see noted something really strange in my logs

IBcDUlzwLHEbGrQj (this is an UID) 216.39.48.81(trek5.sv.av.com) Scooter/3.2 (this time this is the altavista bot :)

and few hours later

IBcDUlzwLHEbGrQj (this is the same UID) 207.162.228.12 (s3-1.bear.com) Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705) (looks like a human being this time :)

I just cannot imagine scooter using it's spare time to browse our web-site with MSIE 6.0, don't think it's interested in the type of goods we sell

this is not the only example of double-uids, googlebot was shopping with us too :)

any idea why this can happen?

hakre

7:32 am on Jul 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi Furmanov,

this looks really a strange behavior. Looks like something is cached. But nevertheless, maybe php can help solve this issue. Did you checked out the uniqid [php.net] function.

Some people are reporting that the mt_rand function is not that reliable for creating random numbers which differ - so feel free to check it out.
-hakre

Furmanov

1:00 pm on Jul 23, 2003 (gmt 0)

10+ Year Member



thanks, hakre

really have no idea what could be cached :(

will try to use this

$UID=md5(uniqid(rand(),1));

will see if it helps

thanks again!