【发布时间】:2022-03-02 00:01:00
【问题描述】:
我已经为控制器登录放置了codeigniter代码。我想在注销后清除缓存。
function logout()
{
$this->session->sess_destroy();
$this->index();
}
【问题讨论】:
标签: php codeigniter
我已经为控制器登录放置了codeigniter代码。我想在注销后清除缓存。
function logout()
{
$this->session->sess_destroy();
$this->index();
}
【问题讨论】:
标签: php codeigniter
clearstatcache — 清除文件状态缓存。这个函数缓存了特定文件名的信息,所以你只需要调用clearstatcache(),php内置函数。
清除浏览器缓存页面:
header ("Expires: ".gmdate("D, d M Y H:i:s", time())." GMT");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
【讨论】:
试试这个
function delete_cache($uri_string=null)
{
$CI =& get_instance();
$path = $CI->config->item('cache_path');
$path = rtrim($path, DIRECTORY_SEPARATOR);
$cache_path = ($path == '') ? APPPATH.'cache/' : $path;
$uri = $CI->config->item('base_url').
$CI->config->item('index_page').
$uri_string;
$cache_path .= md5($uri);
return unlink($cache_path);
}
如果不行
参考这些
【讨论】:
使用这个
function logout()
{
$this->session->sess_destroy();
$this->cache->clean();
$this->index();
}
清除控制器结构中的浏览器缓存
header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
【讨论】:
如果您想获取数组 cache_item_id 虎钳,那么您可以执行以下操作。
$wildcard = 'latest';
$all_cache = $this->cache->cache_info();
foreach ($all_cache as $cache_id => $cache) :
if (strpos($cache_id, $wildcard) !== false) :
$this->cache->delete($cache_id);
endif;
endforeach;
或者试试这个
函数注销(){
$this->CI =& get_instance();
$this->CI->session->sess_destroy();
$this->cache->clean();
redirect(base_url());
}
【讨论】:
【讨论】:
在您的代码中添加以下脚本
history.pushState(null, null, location.href);
window.onpopstate = function () {
history.go(1);
};
【讨论】: