Show sourcecode
The following files exists in this folder. Click to view.
webbserverprogrammering/exercises/cookie-session/
c-s.php
c-s_1.php
c-s_2.php
c-s_3.php
c-s_2.php
31 lines UTF-8 Windows (CRLF)
<?php
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('output_buffering', 0);
session_start();
?>
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cookie-Session_2</title>
</head>
<body>
<?php
echo "<p>Session id: ".session_id()."</p>";
if (!isset($_SESSION['tid'])) {
$_SESSION['tid'] = time();
echo "<p>Cookies är inte satta, uppdatera sidan!</p>";
} else {
if (time() - $_SESSION['tid'] < 10) {
echo "<p>Välkommen tillbaka!</p>";
$_SESSION['tid'] = time();
} else {
echo "<p>Det har gått mer än tio minuter!</p>";
$_SESSION['tid'] = time();
}
}
?>
</body>
</html>