By kristian on
I'm trying to log in a user as part of a form submit, but why is the following not working:
$user = db_fetch_object(db_query("SELECT * FROM users WHERE mail = '%s' AND pass = '%s'", $mail, md5($pass)));
if ($user) {
// Authenticate user and log in
$params = array(
'name' => $user->name,
'pass' => trim($user->pass)
);
// Authenticate user
$account = user_authenticate($params);
}
if I dump $user I can see the correct values, but if I dump the $account it's empty.
What am I doing wrong?
Comments
Heya, The $user->pass is the
Heya,
The $user->pass is the md5 encrypted password. You need to pass the non md5 version.
cheers
drupal 6 how to programatically logging in user
Hi, i tested and verified on drupal 6 and below code was working fine.