Migrating PHP Login into WordPress?

So i am using a custom Login form with php using Sessions i would like to know how i can implement this into wordpress.

I have changed the database object to wpdb method successfully however i am now wondering how to implement the session on wordpress?

Read More

Is there a specific way or can i just create a session variable and check for that variable isset on the redirect page?

This is my current php login code without wpdb keep in mind i wont be using the classes:

$database = new MySQL();
$session = new Session($database);

$msg = '';
$msgl = '';
$msgemail = '';
$message = '';

if (isset($_POST['login']) && $session->isLogged == false) {

    $email = $database->escapeString($_POST['user_email']);
    $pass = sha1($database->escapeString($_POST['user_pass']));

    $result = $database->executeQuery("SELECT user_id, user_type from `user-tbl` WHERE `billing_email`='$email' AND `account_password`='$pass'");

    if ($database->numRows($result) == 1) {
        $row = $database->fetchResult($result);

        $_SESSION['account_id'] = $row['user_id'];
        $_SESSION['account_type'] = $row['user_type'];
        $_SESSION['security'] = hash('md5', $_SERVER['HTTP_USER_AGENT']);

        if (isset($_POST['store'])) {
            $_SESSION['store'] = 1;

            $session->storeCookie();
        } else {
            $_SESSION['store'] = 0;
        }

        $location = 'Location: ';
        if ($row['user_type'] == "customer") {
            $location .= '/account.php';
        } elseif ($row['user_type'] == "admin") {
            $location .= '/admin/account.php';
        } elseif ($row['user_type'] == "employee") {
            $location .= '/employee/account.php';
        }

        header($location, true);
    } else {
        $msg = "Please Enter Correct E-mail OR Password.";
    }
}

Thanks for your input!

Related posts