-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.php
More file actions
21 lines (18 loc) · 680 Bytes
/
Copy pathvalidate.php
File metadata and controls
21 lines (18 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
if(isset($_POST['username'], $_POST['password'])){
$username = $_POST['username'];
$password = $_POST['password'];
//1) Hard coded user credentials
if($username == 'user' && $password == 'user'){
// 2) Generate session identifier and set as a cookie in the browser
$sessionIdentifier = base64_encode(openssl_random_pseudo_bytes(32));
setcookie("sessionID", $sessionIdentifier);
// 2) Generate the CSRF token and set as a cookie in the browser
$csrfToken = base64_encode(openssl_random_pseudo_bytes(32));
setcookie("tokenID", $csrfToken);
header('Location:form.php');
} else {
header('Location:index.php');
}
}
?>