Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Logout user by deleting cookie

 
Leonardo Pjetri
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is how the cookie is detected

im trying to add a button, when clicked it kills the cookie, but so far no success
thanks
 
Gaurav Chhabras
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public void Cookie.setMaxAge(int expiry)

Specifies the maximum age of the cookie in seconds before it expires. A negative value ( -1 ) indicates the default, that the cookie should expire when the browser exits. A zero ( 0 ) value tells the browser to delete the cookie immediately.

you can do one thing that on click of button , you can write the code ..

yourCookieName.setMaxAge(0);

It will delete the cookie immediately.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic