<?php // classes/aux_SafeCookie.php
/**
* Damage a cookie
*/
error_reporting(E_ALL);
$cookie_name
= !empty($_GET['n'])
? $_GET['n']
: NULL
;
$cookie_value
= !empty($_GET['v'])
? $_GET['v']
: NULL
;
$host = $_SERVER['HTTP_HOST'];
if (substr_count($host, '.') > 1) {
$host = explode('.', $host);
unset($host[0]);
$host = implode('.', $host);
}
setcookie
( $cookie_name
, $cookie_value
, time() + 3600 // One hour into the future
, '/' // All sub-directories
, $host // Host name
, FALSE // OK to set on HTTP (not just HTTPS)
, TRUE // Restricted from Javascript
)
;
echo PHP_EOL . "Cookie '$cookie_name' has been set to '$cookie_value'";
|