HOW DO YOU DELETE A COOKIE WITHIN A JSP?

Awadhendra Tiwari

Total Post:505

Points:2525
Posted by  Awadhendra Tiwari
Java 
 1378  View(s)
Ratings:
Rate this:
  1. Awadhendra Tiwari

    Post:505

    Points:2525
    How do you delete a Cookie within a JSP?

    We can create a cookie in jsp by using following code snippet

    Cookie cook1= new Cookie("name","value");
    response.addCookie(cook1);
    

    We can delete cookie using following code snippet

    Cookie killmycook = new Cookie("cook1","value");
    killmycook.setMaxAge(0);
    killmycook.setPath("/");
    killmycook.addCookie(killmycook);
    

      Modified On Mar-27-2018 12:42:23 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!