Abu Romaïssae
Abu Romaïssae

Reputation: 3901

Remove cookie upon leaving the webpage

Is there a way to delete ALL cookies upon leaving the web application automatically ?

knowing that he can leave the web page by clicking on a link, closing tab, clicking on home page button, etc.

Upvotes: 0

Views: 5956

Answers (2)

Iman
Iman

Reputation: 381

The cookie would save in client's machine, if you want to close cookie on close window you can set a session cookie, will automatically expire when session closed. but if you want to close cookie on close tab you can use javascript event on close tab such as window.onclose to delete all cookies.

Upvotes: 4

Shurmajee
Shurmajee

Reputation: 1047

If you are using java set the age of the cookie=-1 this will make sure that the cookie is deleted when the browser closes. In case user is logging out by clicking on a link make cookie age=0 this will delete the cookie.have a look at

http://docs.oracle.com/javaee/1.3/api/javax/servlet/http/Cookie.html

Upvotes: 0

Related Questions