Skip to content

Commit 86cebd5

Browse files
Add limit for failed attempts
1 parent 0785467 commit 86cebd5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

unzip.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
session_start();
55
$username = 'vue';
66
$password = '123456';
7+
$maxWrongAttempts = 100;
8+
if (isset($_SESSION['wrong_attemtps_count']) && $_SESSION['wrong_attemtps_count'] > $maxWrongAttempts) {
9+
die('Too many attempts');
10+
}
11+
712
$_SESSION['message'] ='';
813
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST) && isset($_POST['logout'])) {
914
session_destroy();
@@ -16,6 +21,10 @@
1621
$_SESSION['username'] = $username;
1722
} else {
1823
$_SESSION['message'] ='Username or password is wrong';
24+
if (!isset($_SESSION['wrong_attemtps_count'])) {
25+
$_SESSION['wrong_attemtps_count'] = 0;
26+
}
27+
$_SESSION['wrong_attemtps_count']++;
1928
}
2029
}
2130

0 commit comments

Comments
 (0)