reklaw has asked for the wisdom of the Perl Monks concerning the following question:
$passhash was written to a file with the user's name earlier on (in newuser.pl):# !perl use CGI qw(:standard); # use the CGI libraries print header; # start the html output $username = param('username'); # take <input name=username> $password = param('password'); # take <input name=password> + open(FILE, "./users/$username"); # open the user's file in $use +rs $passhash = <FILE>; # read the password hash from the f +ile close(FILE); # close the file if (crypt($password, $passhash) eq $passhash) { print "You are now logged in."; } else { print "Incorrect username or password, please try again."; }
My question is: how can I set it so that the user can stay logged in between pages (eg. use a cookie) without storing the password somewhere in plaintext to check $passhash against? Sorry if I've gone about this whole thing completely the wrong way.$salt = join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z') [rand 64, rand 6 +4]; # create random two-character salt $passhash = crypt($password, $salt); # hash the password with t +he salt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: setting a cookie on login
by atcroft (Abbot) on May 21, 2004 at 18:01 UTC | |
|
Re: setting a cookie on login
by Joost (Canon) on May 21, 2004 at 21:58 UTC | |
|
Re: setting a cookie on login
by waswas-fng (Curate) on May 21, 2004 at 18:25 UTC | |
by ambrus (Abbot) on May 21, 2004 at 20:45 UTC | |
|
Re: setting a cookie on login
by Joost (Canon) on May 21, 2004 at 22:05 UTC |