很高兴见到你.我有一些问题.
如何使用HTML或JavaScript禁用Cookie?
所有互联网的答案都是设置为昨天的过期时间.喜欢下的代码.
var date = new Date(); date.setDate(date.getDate() - 1); var willCookie = ''; willCookie += 'CookieName=Value'; willCookie += 'expires' + date.toUTCString(); document.cookie = willCookie;
如何在HTML或JavaScript中创建cookie?不是浏览器.
如果正在设置cookie,它将阻止
if(!document.__defineGetter__) { Object.defineProperty(document, 'cookie', { get: function(){return ''}, set: function(){return true}, }); } else { document.__defineGetter__("cookie", function() { return '';} ); document.__defineSetter__("cookie", function() {} ); }
对于PHP:
$dirty = false; foreach(headers_list() as $header) { if($dirty) continue; // I already know it needs to be cleaned if(preg_match('/Set-Cookie/',$header)) $dirty = true; } if($dirty) { $phpversion = explode('.',phpversion()); if($phpversion[1] >= 3) { header_remove('Set-Cookie'); // php 5.3 } else { header('Set-Cookie:'); // php 5.2 } }
使用Javascript: