How to efficiently clear the session after logout

Brief description

  Because I have never done login persistence, usually logout is a direct jump, regardless of session or session, so when considering this operation today, I intend to directly control it through js; after studying for a while, I want to use the database Store a state value for control, but it feels too cumbersome, and then suddenly thought that you can link to the login page through a jump link, and then delete the session directly on the login page, which is convenient and fast, so record it.

achieve

  • Exit link
<li>
  <a href="../login.jsp" class="logout"><i class="iconfont icon-power-off"></i><span>退出</span></a>
 </li>
  • Clear the specified session
  // 退出清除指定session
    <%
       session.removeAttribute("myUser");
   %>
 // 退出清除全部session
    <%
       session.invalidate();
   %>
 	

Show results

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_41071754/article/details/110008134