如何在此 PHP 文件中添加 cookie

How to add cookies in this PHP file

Help me add cookies

Here are session but would like to add and cookies to maintain logged more.

Login

    // Login
if($_POST['login_submit']){
$LOGIN['Email'] = mysql_real_escape_string($_POST['Email']);
$LOGIN['password'] = mysql_real_escape_string($_POST['login_password']);
$LOGIN_QUERY = "SELECT * FROM users WHERE email='".$LOGIN['Email']."' AND password='".$LOGIN['password']."'";
$LOGIN_RESULT = mysql_query($LOGIN_QUERY);
$LOGIN_ROW = mysql_num_rows($LOGIN_RESULT);
if(mysql_num_rows($LOGIN_RESULT)) {
    $LOGIN_ROW = mysql_num_rows($LOGIN_RESULT);
        $_SESSION['id'] = $LOGIN_ROW['id'];
        $_SESSION['username'] = $_POST['Email'];
        $_SESSION['password'] = $_POST['login_password'];
        header('Location: /home');
} else {
        header('Location: ');
}
}

function get_members

function get_members($id)
{
    db_connect();

    $query = ("SELECT * FROM users WHERE username='".$_SESSION['username']."' OR email='".$_SESSION['username']."' ");

    $result = mysql_query($query);

    $row = mysql_fetch_array($result);

    return $row;
}

form Login

<form class="Container" name="" action="/" method="POST">
    <div class="field">
        <label>Email</label>
        <input name="Email" type="email" name="Email" id="Email" value="" autofocus="autofocus">
    </div>
    <div class="field">
        <label>Password</label>
        <input name="login_password" type="password" name="Password" id="Password" value="">
    </div>
    <div class="btn-container">
        <input name="login_submit" type="submit" class="submit_button" value="Login in">
    </div>
</form>

Please help me if you can.

I need very strong

  1. $_SESSION['username'] = $_POST['Email'];改成setcookie('username', $_POST['Email'], time()+86400);,同pswd.

  2. 在函数 get_members 中,将 $_SESSION['username'] 更改为 $_COOKIE['username']

  3. 不要直接存pswd,先用md5()