-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcookies.php
41 lines (40 loc) · 1.49 KB
/
cookies.php
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
<?php
$cookie_name = "author";
$cookie_value = "Nasir Khan";
setcookie($cookie_name, $cookie_value, time() + (60 * 60 * 24 * 30), "/"); // 60 seconds, 60 minutes, 24 hours, 30 days
?>
<!doctype html>
<html lang="en">
<head>
<?php require_once "_header.php" ?>
<title>Cookies</title>
</head>
<body>
<?php require_once "_navbar.php" ?>
<div class="container">
<div class="row justify-content-center mt-5">
<div class="col-12 col-sm-6 align-self-center">
<div class="card">
<div class="card-body text-center">
<h1>Cookies</h1>
<hr>
<?php
if(count($_COOKIE) > 0) {
if(!isset($_COOKIE[$cookie_name])) {
echo "Cookie named '" . $cookie_name . "' is not set!";
} else {
echo "Cookie '" . $cookie_name . "' is set!<br>";
echo "Value is: " . $_COOKIE[$cookie_name];
}
} else {
echo "Cookies are disabled.";
}
?>
</div>
</div>
</div>
</div>
</div>
<?php include_once "_footer.php" ?>
</body>
</html>