如何销毁会话与浏览器关闭在codeigniter 3 [英] How to destroy session with browser closing in codeigniter 3
本文介绍了如何销毁会话与浏览器关闭在codeigniter 3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
首先,我要提醒您,我已阅读这个问题,我使用 Codeigniter 3 。
我想破坏会话与浏览器关闭像PHP会话!
我已经阅读了关于使用ajax的某些事情,像这样:
First of all I should remind you I have read this question , I am using Codeigniter 3 . I want to destroy session with browser closing like PHP session ! I have read somethings about using ajax like this :
var unloadHandler = function(e){
//here ajax request to close session
};
window.unload = unloadHandler;
和....
但我不想让自己依赖于js for destroy会话与浏览器关闭。
这是我的 config.php
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'soheil_blog_name';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
推荐答案
你只需将sess_expiration设置为0,如手册和 config.php comments 。
You just have to set 'sess_expiration' to 0, as described in the manual and in the config.php comments.
注意:从技术上讲,当浏览器关闭时,你不能真正地销毁会话。您只能告诉浏览器在关闭后丢弃会话cookie,但会话本身仍然可以在服务器端使用(即,如果您是MITM攻击的受害者,并且有人窃取了会话ID)。
会话实际上被垃圾回收器删除。
这篇关于如何销毁会话与浏览器关闭在codeigniter 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文