Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

JSP Cookies

Options
  • 04-04-2006 11:32am
    #1
    Registered Users Posts: 1,987 ✭✭✭


    This is a cookie i created, when i click logoff i want the cookies to be killed/deleted or its values set to null, which is the right way and best way to do it?
    Date now = new Date();
       String timestamp = now.toString();
       Cookie cookie = new Cookie ("username",username);
       cookie.setMaxAge(365 * 24 * 60 * 60);
       response.addCookie(cookie);
    


Comments

  • Moderators, Politics Moderators Posts: 39,929 Mod ✭✭✭✭Seth Brundle


    any use?
    <%
         Cookie cookie = new Cookie("username", null);
         cookie.setMaxAge(0);
         cookie.setPath("/");
         response.addCookie(cookie);
    %>
    


  • Registered Users Posts: 1,987 ✭✭✭Ziycon


    Whats this line do?
    cookie.setPath("/");
    


  • Moderators, Politics Moderators Posts: 39,929 Mod ✭✭✭✭Seth Brundle


    Its not necessary actually - I copied the code quickly from elsewhere.


  • Registered Users Posts: 1,987 ✭✭✭Ziycon


    doesnt work, tired changing the code round, anyone else know??


  • Moderators, Politics Moderators Posts: 39,929 Mod ✭✭✭✭Seth Brundle


    Is my example removing the username value? Is it removing the max age value?
    What exactly is not working?


  • Advertisement
  • Registered Users Posts: 1,987 ✭✭✭Ziycon


    nothin at all happens that i can see, the cookie is still alive and the pages all load fine, no changes!


Advertisement