hip1/11.6.php
<?php
if(isset($_GET['toonmenu'])){
setcookie('toonmenu',$_GET['toonmenu'], time() + 52*7*24*60*60);
$toonmenu = $_GET['toonmenu'];
$mes = "De cookie toonmenu is gewijzigd in: ".$_GET['toonmenu'];
$oude = $_COOKIE['toonmenu'];
$mes .= "<br>De oude waarde was: $oude";
}
elseif(isset($_COOKIE['toonmenu'])){
$toonmenu = $_COOKIE['toonmenu'];
$mes= "De cookie toonmenu is uitgelezen. De waarde is $toonmenu";
}
else{
setcookie('toonmenu',0, time() + 52*7*24*60*60);
$mes= "Dit was het eerste bezoek. De cookie toonmenu is nu 0";
$toonmenu = 0;
}
?>
<html>
<head>
<style>
#menu{
float:left;
width:100px;
border-right:solid 1px black;
margin-right:10px;
min-height:200px;
}
</style>
</head>
<body>
<?php
if($toonmenu==1){
echo "<div id='menu'>
<div><a href='http://www.google.nl/'>Google</a></div>
<div><a href='http://www.facebook.com/'>Facebook</a></div>
<div><a href='http://www.microsoft.com/'>Microsoft</a></div>
</div>";
}
echo $mes;
?>
<p>
<div><a href='11.6.php?toonmenu=0'>Stel toonmenu in op 0</a></div>
<div><a href= '11.6.php?toonmenu=1'>Stel toonmenu in op 1</a></div>
<div><a href= '11.6.php?toonmenu='>Verwijder cookie toonmenu</a></div>
<div><a href= '11.6.php'>Herlaadt pagina</a>
</p>
</body>
Resultaat
Made by Thijs Aarnoudse