会话毁坏在codeigniter中无法正常工作 标题代码
if($session_data!="" AND $session_data['is_business_admin']=="1" AND $session_data['is_system_admin']=="0" AND $session_data['is_super_admin']=="0" )
{
echo "business_admin is logout";
echo " Welcome <i>" . $session_data['first_name'] . "</i> !";
?>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
<ul style="display: none;" class="dropdown-menu">
<li><a href="<?php echo site_url('Admin/dashboard/'); ?>">Dashboard</a></li>
<li class="divider"></li>
<li><a href="<?php echo site_url('Admin/logout/'); ?>">Logout</a></li>
</ul>
</li>
</ul>
<?php }
控制器代码
public function logout() {
// Destroy session data
$this->session->sess_destroy();
$data['message_display'] = 'Successfully Logout';
$message = "you are successfully logout";
echo "<script type='text/javascript'>alert('$message');</script>";
//$this->load->view('login', $data);
$this -> login();
}
答案 0 :(得分:1)
在__construct
function __construct()
{
parent::__construct();
ob_start(); # Add this
$this->load->library('Session');
}
并在 退出/会话销毁 部分添加此
$this->load->driver('cache');
$this->session->sess_destroy();
$this->cache->clean();
redirect(''); # your home controller
ob_clean();
答案 1 :(得分:0)
使用
$this->session->unset_userdata('username_or_key_used_to_check_login');