2
這是用於登錄功能的腳本。但是,如果我想添加一個計時器到會話中,它會忽略它。我已經嘗試了10秒,或1分鐘。但它似乎並不奏效。有人知道發生了什麼問題嗎?PHP會話計時器被忽略
這是代碼的即時使用定時器的線路:session_set_cookie_params(3600,"/");
感謝正手。
public function login($username, $password) {
$salt="";
$this->user_id=0;
$this->status=0;
$salt_query=$this->mysqli->query(
<<<EOT
SELECT salt
FROM xxxxx
WHERE username="{$username}"
EOT
);
$salt_query = $salt_query->fetch_row();
$salt = $salt_query[0];
$hash = hash('sha512', $password.= $salt);
$result = $this->mysqli->query(
<<<EOT
SELECT werknemer_id,status
FROM xxxxx
WHERE username="{$username}" AND password="{$hash}"
EOT
);
$rij =$result->fetch_row();
if ((empty($rij)) || (empty($rij[0]))) return(1);// Invalid combination
if (($rij[1]<1) || ($rij[1]>2)){
return(2); // Inactive account
}
$this->user_id=intval($rij[0]);
$this->status=intval($rij[1]);
session_regenerate_id();
$_SESSION['werknemer_id']=$this->user_id;
session_set_cookie_params(3600,"/");
return(0); // login
}