ページのコンテンツを制御しようとしています。セッション/クッキーを追加または削除する必要があるように。正常に動作するクラスを作成しましたが、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;");
}
等...
私のクラスは:
<?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));
*/
?>
何かお手伝いできますか?