防止mozilla会话恢复

防止mozilla会话恢复

问题描述:

Mozilla能够恢复我的Java EE银行应用程序的会话(关于崩溃,恢复会话选项)。防止mozilla会话恢复

有没有办法通过编写代码来阻止mozilla恢复会话? 还是有可能确定出现在会话恢复中的请求,并强制用户再次登录?

如果您需要的是无效的网页浏览器崩溃后,你应该使用驱动缓存行为的HTTP标头:

<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> 
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE"> 
<META HTTP-EQUIV="EXPIRES" CONTENT="0"> 

M.

+0

谢谢,但即使添加上面的头后,Firefox可以在崩溃后恢复会话。 – SunilGiri 2012-07-12 05:03:41

我不知道,如果它回答你的问题直接,但你可以关闭恢复以前的会话。从mozilla下面的链接的详细信息。

http://support.mozilla.org/en-US/kb/restore-previous-session#w_configuring-session-restore

看起来像这样还不存在(如2013年3月4日的)。希望浏览器开发人员能够理解会话恢复会带来安全漏洞。

我正在调查相同的问题。

正如我认为让浏览器恢复旧会话通常是一个坏主意。 然而,我尝试了几件事情,例如设置缓存控制标题,但这不适用于我。

所以我的确在考虑在脚本中解决这个问题。

但是,我看到不同的解决方案的问题。

1)删除在浏览器关闭 饼干 - >问题:你应该用JavaScript添加漏洞做到这一点,因为http_only应该从0(当浏览器关闭设置为false

2)设置cookie_lifetime)至例如3600(1小时)。 - >问题:将此设置为高并且安全性丢失并将其设置为低会给用户提供'会话过期'错误消息,这意味着他们必须重新登录。

3)添加第二个带有效日期的cookie。如果cookie在那里一切正常。 - >问题:是(几乎)与2)相同,只有在设置cookie之后才能更改到期日期时,此功能才有效。在这种情况下,用户应保持活动至少XX分钟,否则他会放松会话(对我来说似乎是正确的)。

我自己会看看后面的一个。

因此,在这种情况下,我使用PHP(不是Java),但我想总的想法是一样的:

//create expiration cookie 
private function setExpireCookie(){ 

    //expire cookie: name, value, expiration in seconds, path, domain, https, http-only 
    setcookie("Test_Expire", "Expire", time()+3600, "/test", null, false, true); 
} 

//check if expiration cookie exits 
private function expireExists() { 

    return isset($_COOKIE['Test_Expire']); 

} 

//set the session check for expiration cookie 
private function getSession() { 

    //does the session cookie exists and the expiration cookie doesnt? 
    if (!$this->expireExists() && isset($_COOKIE['Test_Cookie'])) { 

     //to remove the cookie by setting the expiration time before now 
     setcookie("Test_Cookie", $_COOKIE['Test_Cookie'], time()-3600, "/test"); 
    } 

    //now we can set the new expiration cookies en start the new session 
    $this->setExpireCookie(); 

    //set cookie params: lifetime, path, domain, https, http-only 
    session_set_cookie_params(0, "/api", null, false, true); 

    session_name('Test_Cookie'); 

    //start session 
    session_start(); 
} 

此作品脱颖而出我。所以希望你可以申请这个在Java

+0

嘿! ;)没有理由拒绝投票。我创建了一个工作:-) – BonifatiusK 2013-03-25 12:03:24

+0

感谢您的编辑,现在它已被撤消。 – 2013-03-25 15:52:29