Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/exercises/cookies och session/

hemligsida.php
index.php
ovn_cs1 copy.php
ovn_cs1.php
ovn_cs2.php
ovn_cs3.php
ovn_cs4.php

ovn_cs2.php

32 lines UTF-8 Windows (CRLF)
<?php
error_reporting
(-1); // Report all type of errors
ini_set('display_errors'1); // Display all errors
ini_set('output_buffering'0); // Do not buffer outputs, write directly
?>

<?php
session_start
();
?>

<!DOCTYPE html>
<html lang="sv">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>COOKIESnSESSION</title>
</head>

<body>

<?php
if (isset($_SESSION["lastLoad"]) && time() - $_SESSION["lastLoad"] < 10){
    
// Om man har variabeln sparad och det är mindre än 10 s sedan man senast laddade sidan
    
echo("Hej, du var här nyligen");
}
$_SESSION["lastLoad"] = time(); // Sparar tiden för det här anropet
?>

</body>

</html>