my code to making cookie in jsp. Cookie cookie= new Cookie("iAdminName",iAdminName); cookie.setMaxAge(-1); response.addCookie(cookie); Code (markup): to remove cookie i use this Cookie killMyCookie = new Cookie("iAdminName", null); killMyCookie.setMaxAge(0); killMyCookie.setPath("/"); response.addCookie(killMyCookie); Code (markup): problem is cookie is not removed, is there a bug in my coding? how i remove cookie? I worked on JSP & JAVA, this is the source code of JSP file.
Why are you making another object, don't you need to use the same object? Cookie cookie= new Cookie("iAdminName",iAdminName); cookie.setMaxAge(-1); response.addCookie(cookie); cookie.setValue(null); cookie.setMaxAge(0); cookie.setPath("/"); Code (markup):
My psychic powers tell me... ...your original cookie has a different path. I suspect he kills the cookie on a different page.
yea lolz as CDarklock said u saving cookie in diffrent path and deleteing cookie of diffrent path try this : Cookie killMyCookie = new Cookie("iAdminName", null); killMyCookie.setMaxAge(-0); killMyCookie.setPath(request.getHeader("host")); response.addCookie(killMyCookie); Code (markup):