注销后清除缓存

时间:2013-11-19 08:54:27

标签: php codeigniter

我已经为控制器登录设置了codeigniter代码。我希望在注销后清除缓存。

function logout()
    {
        $this->session->sess_destroy();

        $this->index();

    }

6 个答案:

答案 0 :(得分:0)

使用此

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");

check this

答案 1 :(得分:0)

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");

答案 2 :(得分:0)

试试这个

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);
}

如果不起作用

参考这些

Lib

manual

答案 3 :(得分:0)

您只需在logout函数中添加以下代码:

$this->cache->clean();

有关codeigniter中缓存的更多信息,请参阅this

答案 4 :(得分:0)

如果您想获取数组cache_item_id vise,那么您可以执行以下操作。

$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;

或试试这个

function logout(){

         $this->CI =& get_instance();   
         $this->CI->session->sess_destroy();
         $this->cache->clean();
         redirect(base_url());
}

答案 5 :(得分:0)

在代码中添加以下脚本

history.pushState(null, null, location.href);
window.onpopstate = function () {
    history.go(1);
};
相关问题