我即将控制我的页面内容。所以我需要添加或删除会话/cookie。我做了一个工作正常的课程,但在 cookie 问题上,它不能正常工作。我检查了 windows7 中的 firefox 18 和 ubuntu 12.04 LTS。cookie 不会被删除
setcookie(name, '', time()-9600)
foreach($this->_ck as $cookie)
{
$hrs=0;
if($plus)
{
$hrs=3600*$cfg_cookie_time;
}
//setcookie('testcookie13', '', time()-3600*6);
header("Set-Cookie: ".$cookie."=deleted; expires=Sun, 01-Jul-2012 08:59:12 GMT;");
}
ETC...
我的课是:
<?php
class headers{
var $new;
var $vars;
var $ss;
var $ck;
var $_ss;
var $_ck;
var $error;
var $catchs;
function _construct()
{
$this->new=false;
$this->error=false;
$this->ss=array();
$this->ck=array();
$this->_ss=array();
$this->_ck=array();
$this->catchs=true;
return $this->catchs;
} //f
function headers($hs = array(
"set" => array(
"ss" => array(),
"ck" => array()
)
))
{
if(isset($hs['send']))
{
$this->new=$hs['send'];
$this->catchs=true;
}
if(is_array($hs['set']))
{
if(is_array($hs['set']['ss']))
{
$this->ss = $hs['set']['ss'];
}
if(is_array($hs['set']['ck']))
{
$this->ck = $hs['set']['ck'];
}
}
if(is_array($hs['unset']))
{
if($hs['unset']['ss'])
{
$this->_ss = $hs['unset']['ss'];
}
if(is_array($hs['unset']['ck']))
{
$this->_ck = $hs['unset']['ck'];
}
}
return $this->catchs;
} //f
function send(
$cfg_cookie_time=6,
$plus=true
)
{
$cookie='';
if(is_array($this->ss))
{
session_start();
foreach($this->ss as $session){
$_SESSION['session'] = $session;
}
}
if($this->_ck)
{
foreach ($_COOKIE as $name => $value) {
setcookie($name, '', 1);
}
}
if($this->ck)
{
foreach($this->ck as $cookie => $val)
{
//$this->ck=$cookie.$val;
$hrs=0;
if($plus)
{
$hrs=3600*$cfg_cookie_time;
}
header("Set-Cookie: ".$cookie."=".$val."; path=/; domain=".$_SERVER['HTTP_HOST']."; expires=".gmstrftime("%A, %d-%b-%Y %H:%M:%S GMT;", time()+$hrs));
}
}
if($this->new)
{
header("location: ".$this->new);
$this->catchs=false;
}
header("X-Powered-By: PHP ".phpversion()."/FxPHP");
//header("HTTP/1.0 404 Not Found");
return $this->ck;
} //f
} // class
setcookie('H', '', -3600);
/*$hr = new HEADERS( array
(
"set" => array
(
"ck"=> array(),
"ss"=> array()
),
"unset" => array
(
"ck"=> array
(
"H" => "H"
),
"ss"=> array()
)
)
);
print_r( $_COOKIE).print_r($hr->send());
/*
" f" => "" ,
" sf" => "",
"my"=> "" ,
print_r(getallheaders());
print_r(setcookie('sd', 'dsds', 3600*6));
*/
?>
你能帮忙吗?