title: How to remove a cookie
body: <p>I am trying to implement the logout functionality for my iPhone app, which uses jQuery mobile, JS at the client side and java at the server side. Currently what I have to do is to clear cookie and redirect to #loginpage tag in my index.html (I have only 1 HTML file in which there are multiple tags for the different pages). What I am doing as of now for the clearCookie is: </p>
  
  <pre><code>Cookie readCookie = null;
  for (Cookie cookie : httpRequest.getCookies()) {
      if (cookie.getName().equals("CookieForLogin")) {
          readCookie = cookie;
          break;
      }
  }
  
  readCookie.setMaxAge(0);
  httpResponse.addCookie(readCookie);
  </code></pre>
  
  <p>But this code is not clearing the cookie. I have tried the JS ways, i.e. to set the expiration date to some previous date, given on net but they didn't work too. Also I don't have a response method for <code>HttpServletResponse</code>. How do I clear the cookie that is set at the client side &amp; also how to redirect to a particular tag?</p>