<?php
define('SECRETKEY', 'quis custodiet ipsos custodes');
if (isset($_COOKIE['stamp'])) {
if ($_COOKIE['stamp'] == sha1($_COOKIE['data'] . SECRETKEY)) {
echo "Validated!\n";
} else {
echo "<blink>Not validated</blink>";
}
} else {
$_COOKIE['data'] = '00110100011';
$_COOKIE['stamp'] = sha1($_COOKIE['data'] . SECRETKEY);
}
?>
- Easy validation of cookie data
- But not the 'best' way