-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cookies.php
75 lines (73 loc) · 2.53 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
/**
* Created by PhpStorm.
* User: bruno
* Date: 08-Nov-17
* Time: 23:18
*/
if (isset($_POST) && count($_POST) > 0) {
if (isset($_POST["cookie1"])) {
setcookie("cookie1", $_POST["cookie1"], time() + 3600, null, null, null, false);
setcookie("cookie2", $_POST["cookie2"], time() + 3600, null, null, null, true);
}
if (isset($_POST["cookie3"])) {
setcookie("cookie3", $_POST["cookie3"], time() + 3600, null, null, false, null);
setcookie("cookie4", $_POST["cookie4"], time() + 3600, null, null, true, null);
}
header("Refresh:0");
}
?>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h1>Http-only & secure flags</h1>
<h2>Status cookies</h2>
<table class="table table-hover">
<thead>
<tr>
<th>Type</th>
<th>Waarde</th>
</tr>
</thead>
<tr>
<td>Cookie zonder http-only</td>
<td><?php echo isset($_COOKIE["cookie1"])?$_COOKIE["cookie1"]:"(Cookie niet gezet)";?></td>
</tr>
<tr>
<td>Cookie met http-only</td>
<td><?php echo isset($_COOKIE["cookie2"])?$_COOKIE["cookie2"]:"(Cookie niet gezet)";?></td>
</tr>
<tr>
<td>Cookie zonder secure</td>
<td><?php echo isset($_COOKIE["cookie3"])?$_COOKIE["cookie3"]:"(Cookie niet gezet)";?></td>
</tr>
<tr>
<td>Cookie met secure</td>
<td><?php echo isset($_COOKIE["cookie4"])?$_COOKIE["cookie4"]:"(Cookie niet gezet)";?></td>
</tr>
</table>
<button onclick="alert(document.cookie)">Toon cookies via Javascript</button>
<p></p>
<h2>Cookies aanpassen</h2>
<h3>Http-only</h3>
<form class="form-group" method="post">
Cookie zonder http-only: <input type="text" name="cookie1" class="form-control"/>
Cookie met http-only: <input type="text" name="cookie2" class="form-control"/>
<br>
<button type="submit" class="form-control">Opslaan</button>
</form>
</div>
<div class="container">
<h3>Secure</h3>
<form class="form-group" method="post">
Cookie zonder secure: <input type="text" name="cookie3" class="form-control"/>
Cookie met secure: <input type="text" name="cookie4" class="form-control"/>
<br>
<button type="submit" class="form-control">Opslaan</button>
</form>
</div>
</body>
</html>