The following files exists in this folder. Click to view.
m03u02.php62 lines UTF-8 Unix (LF) 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
<?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>