阻止登錄所以我有這樣的代碼:我需要經過3次嘗試
<?php
session_start();
if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
}
if(isset($_SESSION['count'])) {
$_SESSION['count']++;
$num = 3 - $_SESSION['count'];
echo $num.' login attempts left.';
if($_SESSION['count'] < 0)
{
session_destroy("count");
unset($_SESSION["count"]);
echo 'negative :/';
}
}
if($_SESSION['count'] == 3)
{
echo 'Your session is locked for 30 minutes.';
if(!$_SESSION['timeout'])
{
$_SESSION['timeout'] = time();
}
$st = $_SESSION['timeout'] + 180; //session time is 30 minutes
if(time() < $st)
{ }
elseif(time() >= $st) {
session_destroy("count");
session_destroy("timeout");
unset($_SESSION['count']);
unset($_SESSION['timeout']);
}
}
?>
某處是一個錯誤,但我不能找到它:( 我只需要限制登錄嘗試不使用數據庫,只是簡單的會話。
你能幫助我嗎?
爲什麼不使用與'write'&'read'文件? –
你在哪裏檢查他們登錄? – chris85
「某處是錯誤」 - 你怎麼知道有錯誤?是否顯示錯誤?腳本沒有做到它應該做的事情嗎? –