Login function in PHP 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.
    

Class User
{
    private $db;

    public function __construct($db)
    {
        $this-&gt;db = $db;
    }

    public function Login($user_email, $user_pass, $remember = false)
    {
        $user_pass = sha1($user_pass);
        $query = $this-&gt;db-&gt;prepare("SELECT id, password FROM users WHERE email = :email");
        $query-&gt;bindValue(':email', $user_email);
        $query-&gt;execute();

        if($query-&gt;rowCount() &gt; 0) {
            $user = $query-&gt;Fetch(PDO::FETCH_OBJ);
            if($user-&gt;password == $user_pass) {
                $_SESSION['loggd_id'] = $user-&gt;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.';
        }

    }
}
I'm using SHA-512 right now but I think I'll change it to mcrypt later. 


Neither of those are the proper tool for the job. Mcrypt is meant for symmetric encryption (AES, TwoFish, DES, etc.), not password hashing.

If you're running PHP 5.5+, use password_hash() and password_verify()

Otherwise, https://github.com/ircmaxell/password_compat is the way to go.

EDIT: Example code:

&lt;?php
Class User
{
    private $db;

    public function __construct($db)
    {
        $this-&gt;db = $db;
    }

public function Login($user_email, $user_pass, $remember = false)
{
        $query = $this-&gt;db-&gt;prepare("SELECT id, password FROM users WHERE email = :email");
        $query-&gt;bindValue(':email', $user_email);
        $query-&gt;execute();

        if($query-&gt;rowCount() &gt; 0) {
            $user = $query-&gt;Fetch(PDO::FETCH_OBJ);
            if (password_verify($user_pass, $user-&gt;password)) {
                $_SESSION['loggd_id'] = $user-&gt;id;
                if($remember == true) {
                    setcookie('lggd_sess', hash('sha512', mcrypt_create_iv(64, MCRYPT_DEV_URANDOM)), 84600);
                    return true;
                }
                return true;
            } else {
                return 'Incorrect Email/Password Combination.';
            }
        } else {
            return 'Incorrect Email/Password.';
        }
    }
}


When you insert a row in the DB, you want to use password_hash($user_password)