Re: Generate unique login token

From: Date: Tue, 10 Feb 2009 07:30:16 +0000
Subject: Re: Generate unique login token
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-288055@lists.php.net to get a copy of this message
2009/2/10 sean greenslade <zootboysean@gmail.com>: > I have a login system that I am coding. I need it to generate a unique token > on login to be stored in the browser's cookie. I currently use a script that > generates a MD5 hash of the current unix timestamp, then checks the mysql > database to see if the token already exists. It loops this generate/check > until it gets a unique token. Is there a better way to do this? I want a > token that cannot be easiy predicted (i.e. not an auto-increment value). > Thanks in advance! I've never had a clash with this on a site with 20m PVPM... $token = sha1($_SERVER['REMOTE_ADDR'].microtime(true)); -Stuart -- http://stut.net/

« previous php.general (#288055) next »