Re: Storing password in cookie

From: Date: Wed, 13 Apr 2005 01:09:57 +0000
Subject: Re: Storing password in cookie
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-212974@lists.php.net to get a copy of this message
Richard Lynch wrote:
On Sat, April 9, 2005 11:51 am, trlists@clayst.com said: *WHY* would you not store some kind of hash of the user ID?! setcookie('remember_me', md5($username)); . . . select username from users where md5(username) = $_SESSION['remember_me'] Is that really any harder?
It's very hard on the database. With no other where clauses to restrict the results set, the database will have to run the md5 routines on every username in the table. For better performance, you should also store something like a record id that you can use... select username from users where recid = $_SESSION['userid'] and md5(username) = $_SESSION['remember_me'] Any query optimizer worth its salt will first filter based on the record ID and then only apply the md5 function to the remaining (1 in this case) usernames. -- D. Wokan

« previous php.general (#212974) next »