2012-05-09 35 views
1

我尝试在JSF 2.0中执行注销功能。首先,我给AUTH_KEY登录用户。注销后,我删除此用户的AUTH_KEY。 我的问题是不注销用户会话不删除。如何删除用户SessionScoped?

科登录功能:

if (startupInfo.getConnectionId().equals("success")) { 
        FacesContext.getCurrentInstance().getExternalContext() 
          .getSessionMap() 
          .put(AUTH_KEY, loggedUserInfo.getUserId()); 
        return "success"; 
       } 

注销

public String logout() { 
    FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove(AUTH_KEY); 

    return "logout"; 
} 

回答

0

你应该在你的注销方法无效的HTTP会话。只删除用户信息不会终止会话:

HttpSession session = (HttpSession) FacesContext.getCurrentInstance() 
         .getExternalContext().getSession(false); 
if (session != null) { 
    session.invalidate(); 
} 
+0

谢谢Matt.I将尝试 – user1360797