How to compare text input with a user password stored in the database? I've been trying to compare password values using a custom form.

Actually I want to show a relogin form after a particular amount of time. So I have created a custom form with two fields – email and password. And now I want to compare the password input from my custom form with the user's password stored in the database. If the passwords are same, then the user will be allowed to access the site agin.

I can't compare the hashed password with the custom form password. I know we can't compare the password values, because the password in the database is hashed.

Is any other way to compare them?
The only advisable approach would be to use user_check_password:

$account = user_load(123);
$valid = user_check_password($password_from_form_submission, $account);
if ($valid) {...}


If you desperately need to do it manually, just copy the parts of that function that make sense for your requirements.