View sourcecode

The following files exists in this folder. Click to view.

m03u02.php

62 lines UTF-8 Unix (LF)
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
<?php
session_start
();

if(isset(
$_GET["action"])){
    switch(
$_GET["action"]){
        case 
"kill":
            
session_unset();
            
session_destroy();
        case 
"killCookie":
            
setcookie('prevName'''time() - 070414);
        }
}

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Ladda om sidan för att se coola saker</title>
    <link rel="stylesheet" href="/spectre/spectre-master/dist/spectre.css">
</head>
<body style="text-align: center;">
    <?php
    
if(isset($_POST["name"])){
        
$_SESSION["name"] = $_POST["name"];
        
setcookie("prevName"$_SESSION["name"]);
    }
    
    if(isset(
$_COOKIE["prevName"])) {
    }

    if(isset(
$_SESSION["name"])){
        echo 
"<h1>Sessionen är satt till:".$_SESSION["name"]."</h1>";
    }
    else{
        echo 
"<h1>Sessionen är inte satt till någonting.</h1>";
    }
    
    
?>
    <h4>Den här sidan använder en cookie, använd på eget bevåg.</h4>
    <form method="Post" action="?">
        <p>
            <label class="form-label" for="textbox">Skriv ditt namn:</label>
            <input id="textbox" name="name" type="text" style="width: 35vw;" 
            <?php
            
if(isset($_COOKIE["prevName"])) {
                echo
"placeholder=\"Senaste namnet (".$_COOKIE["prevName"].") hålls i en cookie\"";
            }
            
?>>
        </p>
        <p>
            <input type="submit" name="submit" value="Skicka" class="btn btn-primary">
        </p>
        <a href="?" class="btn btn-sm">Ladda om sidan</a><br><br>
        <a href="?action=kill" class="btn btn-sm">Döda sessionen</a><br><br>
        <a href="?action=killCookie" class="btn btn-sm">Döda Cookien</a>
    </form>
</body>
</html>