php - cookie


<?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"$valuetime()+3600);  /* expire in 1 hour */
setcookie("TestCookie"$valuetime()+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);
?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值