Show sourcecode
The following files exists in this folder. Click to view.
webbserverprogrammering/exercises/cookies/
ovn_cok1.php
ovn_cok2.php
ovn_cok3_hemligheter.php
ovn_cok3_inloggning.php
ovn_cok4.php
ovn_cok5.php
ovn_cok3_hemligheter.php
61 lines UTF-8 Windows (CRLF)
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
<?php
session_start();
if ($_SESSION["tillåtelse"] === true) {
} else {
header("Location: ovn_cok3_inloggning.php");
die();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hemligheter</title>
</head>
<body>
Per är här.
<form action="" method="post">
<input type="hidden" name="logout" value="true">
<input type="hidden" name="destroy" value="true">
<button type="submit">Logga ut</button>
</form>
<?php
if (isset($_POST["logout"])) {
// Tar bort hela sessionen och rensar allt
if (isset($_POST['destroy'])) {
// Unset all of the session variables.
$_SESSION = array();
// From http://php.net/manual/en/function.session-destroy.php
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(
session_name(),
'',
time() - 42000,
$params["path"],
$params["domain"],
$params["secure"],
$params["httponly"]
);
}
// Finally, destroy the session.
session_destroy();
}
header('Refresh:0');
}
?>
</body>
</html>