HOW DO YOU DELETE A COOKIE WITHIN A JSP?

Awadhendra Tiwari

Total Post:510

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

    Post:510

    Points:2550
    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);
    

Answer

NEWSLETTER

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