knowj wrote:Good point thanks oversight by me.
The hash is just a basic MD5 $this->hash = md5(rand(11111, 99999).date('Ymdhis')); and this is set on login + stored in the database against the users account along with their IP address.
I think your check function is alright and should work.
I see you create hash, adding a value changing with time().
with your format new time value is produced every 1 second.
MD5 of 5 digits number 11111-99999 + date( 'Ymdhis', time() )
I personally do not think this will be more UNIQUE,
than using this example from Official PHP Manual, http://docs.php.net/manual/en/
At least this is shorter: $token = md5( uniqid() );
This uniqid uses current time to generate value.
So it is a higher string value for each new micro-second, uSec ( 1/1.000.000 sec )
Now, md5 of this will change value, so string will not be anymore a constantly increasing value ...!!!!
<?php
//Example#1 uniqid() Example
// works only in PHP 5 and later versions
$token = md5( uniqid() );
// better, difficult to guess
$better_token = md5( uniqid( rand(), true ) );
?>
Note!
Here is the function [man]uniqid/man
Always be sure to read the Comments and CODING submitted by readers.
Especially later comments from 2007 and 2008.
Many times the code submitted can be better, than php.net default examples .....
regars ..to knowj 🙂
from halojoy