似乎我已经遇到了XPages中的SessionListener实现。侦听器在创建会话时将输出打印到日志中,因此我知道它已正确注册。但是,它在注销时不会调用sessionDestroyed。是否有任何特殊的URL重定向我需要执行以使Domino/XPage会话在注销时立即销毁?正如你所看到的,我已经尝试清除范围,并清除尝试启动sessionDestroyed方法的cookie。请注意,当重新启动http服务器任务时,sessionDestroyed不会被调用,所以看起来会话可能会一直存在,直到处于非活动状态超时。SessionListener sessionDestroyed not called
开发服务器是:9.0.1(64位Win7上本地运行) 运行基于会话验证单个服务器(注:我试过了基本身份验证,同样的问题)
注销程序法(SSJS称为):
public static void logout(){
String url = XSPUtils.externalContext().getRequestContextPath() + "?logout&redirectto=" + externalContext().getRequestContextPath();
XSPUtils.getRequest().getSession(false).invalidate();
//wipe out the cookies
for(Cookie cookie : getCookies()){
cookie.setValue("");
cookie.setPath("/");
cookie.setMaxAge(0);
XSPUtils.getResponse().addCookie(cookie);
}
try {
XSPUtils.externalContext().redirect(url);
} catch (IOException e) {
logger.log(Level.SEVERE,null,e);
}
}
简单的会话监听器:
public class MySessionListener implements SessionListener {
public void sessionCreated(ApplicationEx arg0, HttpSessionEvent event) {
System.out.println("***sessionCreated***");
}
public void sessionDestroyed(ApplicationEx arg0, HttpSessionEvent event) {
System.out.println("***sessionDestroyed***");
}
}
这是否有帮助? http://stackoverflow.com/a/11183463/785061 –
感谢您的反馈。在我对这个问题的研究中,我确实找到了这篇文章。我的问题不是会话创建或注册监听器(sessionCreated正在触发)。在使HttpSession失效并执行注销重定向之后,必须处理sessionDestroy。该方法将不会触发,直到我重新启动http和/或如果我等待超时。 –
您是否试过[ExtLib注销控制](http://notesin9.com/index.php/2012/03/09/notesin9-049-xpages-login-and-logout/)? – stwissel