-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.php
More file actions
45 lines (36 loc) · 1.12 KB
/
validate.php
File metadata and controls
45 lines (36 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
function login()
{
$username='admin.sliit@gmail.com';
$passw='admin@cs2018sss';
$input_user= $_POST['inputmail'];
$input_passw= $_POST['inputpassw'];
if(($username == $input_user) && ($passw ==$input_passw )){
//set the cookie parameters
session_set_cookie_params (3600);
session_start();
session_regenerate_id();
//setting the cookie
$cookiename="cookie_name";
$sessionid=session_id();
$time=time()+3600;
setcookie($cookiename,$sessionid,$time,'/');
//token
$tempToken= generateTokenId();
$_SESSION['CSRF_token'] = $tempToken;
echo $tempToken;
//load the page
header('Location:profile.php');
exit;
} else{
echo'<script> document.getElementById("error").style.display = "block";</script>';
}
}
function generateTokenId(){
//$tokenId = crypt(base64_encode(openssl_random_pseudo_bytes(24)));
$tokenId =hash_hmac('sha256',"Hi This is Claude",bin2hex(random_bytes(32)));
return $tokenId;
}
function validateFields(){
}
?>