<?php
// error report
error_reporting(E_ERROR | E_NOTICE | E_PARSE | E_WARNING);
// available stylesheets (filename without .css ending)
$stylesheets = array(
'print',
'phps',
'code-dark',
'twilight',
'espresso',
'term',
'barf',
'notepad++',
'ayti'
);
// track chosen stylesheet permanently
if(isset($_POST['stylesheet']) && $_POST['stylesheet'] !== $_COOKIE['stylesheet'])
$_COOKIE['stylesheet'] = $_POST['stylesheet'];
$default_stylesheet = isset($_COOKIE['stylesheet']) ? $_COOKIE['stylesheet'] : 'ayti';
// Add cookie
setcookie("stylesheet", $default_stylesheet);
// delete cookie
//setcookie("stylesheet", "", 0, "/", "127.0.0.1", false, false);
$default_vector = 'server';
?>
bool setcookie (string$name
[, string$value
[,int$expire
= 0 [,string$path
[, string$domain
[,bool$secure
= false [,bool$httponly
= false ]]]]]] )
If output exists prior to calling this function, setcookie() will fail and returnFALSE
. If setcookie() successfully runs, it will returnTRUE
. This does not indicate whether the user accepted the cookie.
添加cookie
<?php
$value = 'something from somewhere';
setcookie("TestCookie", $value);
setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */
setcookie("TestCookie", $value, time()+3600, "/~rasmus/", "example.com", 1);
?>
删除cookie
<?php
// set the expiration date to one hour ago
setcookie ("TestCookie", "", time() - 3600);
setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", "example.com", 1);
?>