我有一個網站,並希望通過選中框來記住會話。PHP記住我功能不起作用
我有一個代碼來記住用戶名和密碼,但它不起作用,當我重新啓動我的瀏覽器。
下面是代碼:
session_start();
session_regenerate_id();
$_SESSION['id'] = $id;
$_SESSION['mdid'] = $mdid;
$_SESSION['start'] = $start;
$_SESSION['firstname'] = $firstname;
$_SESSION['lastname'] = $lastname;
$_SESSION['username'] = $username;
$_SESSION['email'] = $email;
$_SESSION['password'] = $password;
$_SESSION['country'] = $country;
$_SESSION['city'] = $city;
$_SESSION['joined'] = $joined;
$_SESSION['activation'] = $activation;
$_SESSION['banned'] = $banned;
$_SESSION['ckey'] = $ckey;
// these above variables are from database.
$ctimee = time();
$ckeyy = rand(100000,999999);
mysql_query("UPDATE users SET ckey='$ckeyy', ctime='$ctimee' WHERE id='$id'");
$remember = $_POST['remember'];
if($remember){
setcookie("id", $_SESSION['id'], time()+60*60*24*COOKIE_TIME_OUT, "/");
}
這是一個可怕的,可怕的解決方案。您將用戶的憑據保存在瀏覽器中,每個有權訪問計算機的人都可以從中獲取憑據。 – 2012-02-05 11:32:59
好吧,我刪除了密碼會話,但它仍然不起作用 – 2012-02-05 11:34:27
將密碼設置爲cookie是不可接受的。除此之外,解決問題的信息是無效的。 – dmitry 2012-02-05 11:34:34