title: Logout using servlet
body: <p>I am using this code to logout but still after logout I am able to hit url. Logout seems not working, I am calling this class when clicking on Logout image. Please help.
  Thanks in advance.</p>
  
  <pre><code>public class LogoutServlet extends HttpServlet {
  
      @Override
      public void service(HttpServletRequest request, HttpServletResponse response) {
  
          Cookie[] cookies = request.getCookies();
          if (cookies != null) {
              for (Cookie cookie : cookies) {
                  if (cookie.getName().equals(PermissionDatabase.cookieName)) {
                      cookie.setMaxAge(0);
                      response.addCookie(cookie);
                  }
              }
          }
          Redirect.sendToLogin(response);
      }
  </code></pre>