如何删除会话Cookie? [英] How to Delete Session Cookie?

查看:132
本文介绍了如何删除会话Cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过javascript动态删除会话Cookie,而无需手动重新启动浏览器?

How to dynamically, via javascript, delete a session cookie, without manually restarting the browser?

我在浏览器内存中保留了会话cookie,

I read somewhere that session cookie is retained in browser memory and will be removed when the browser is closed.

// sessionFooCookie is session cookie
// this code does not delete the cookie while the browser is still on
jQuery.cookie('sessionFooCookie', null);

感谢。


更多信息:上面的代码片段是一个
JavaScript代码片段,使用jQuery
及其jQuery.cookie插件。

More Info: The code snippet above is a javascript code snippet, using jQuery and its jQuery.cookie plugin.


推荐答案

会话cookie只是一个没有到期日期的普通cookie。

A session cookie is just a normal cookie without an expiration date. Those are handled by the browser to be valid until the window is closed or program is quit.

但是如果cookie是一个 httpOnly cookie(与 httpOnly parameter set),则不能从HTTP外部读取,更改或删除它。

But if the cookie is a httpOnly cookie (a cookie with the httpOnly parameter set), you cannot read, change or delete it from outside of the HTTP.

这篇关于如何删除会话Cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆