I've been working on a simple login script. The registration part is still to be coded, but I'm done the login part. Are there any security holes in my code? I'm using SHA-512 right now but I think I'll change it to mcrypt later.
Here's the code: <?php
<?php
Class User
{
private $db;
public function __construct($db)
{
$this->db = $db;
}
public function Login($user_email, $user_pass, $remember = false)
{
$user_pass = sha1($user_pass);
$query = $this->db->prepare("SELECT id, password FROM users WHERE email = :email");
$query->bindValue(':email', $user_email);
$query->execute();
if($query->rowCount() > 0) {
$user = $query->Fetch(PDO::FETCH_OBJ);
if($user->password == $user_pass) {
$_SESSION['loggd_id'] = $user->id;
if($remember == true) {
setcookie('lggd_sess', hash('sha512', uniqid()), 84600);
return true;
}
return true;
} else {
return 'Incorrect Email/Password Combination.';
}
} else {
return 'Incorrect Email/Password.';
}
}
}