开发者

How do I remove cookies when the browser is closed? [duplicate]

This questio开发者_运维知识库n already has answers here: Closed 10 years ago.

Possible Duplicate:

Clear cookies on browser close

When I close the browser, I want to remove cookies. How can I do this?


If you don't set an expiry date it defaults to expire at the end of the session . Refer this links -

jscookies


taken from here

function del_cookie(name) {
    document.cookie = name +
    '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
    }

Now all you need to do is to call this del_cookie() function passing it the name of whatever cookie it is that we wish to delete. The function will update the expiry date on the cookie to one long in the past so that the cookie will be considered to be expired and will be ignored by the browser exactly the same as if it didn't exist

to be used something like

<body onload="SetCookie()" onunload="del_cookie()">


You are looking for session cookies.

A tutorial on hwo to create them in JavaScript is available here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜