在PHP中,我在让浏览器删除cookie时遇到了问题。为了解决这个问题,我创建了一个简单的测试页面来完成这个任务:
// Set cookie named MrPants with value foo to expire at end of session
setcookie("MrPants", "foo", 0);
加载该页面后,我在Firefox cookies菜单中看到了cookie。到现在为止还好。
然后,我跟随删除一个cookie:
// Set that cookie's expires time in the past
setcookie
如何删除Java servlet中的cookie?
我试过了:
编辑:下面的代码现在可以正常工作了,它看起来像是以下命令的组合:
response.setContentType("text/html");
和
cookie.setMaxAge(0);
在我这样做之前:
//remove single signon cookie if it hasn't been validated yet
response.setContentType("text/html");
Cookie cookie = new Cookie(SSORealm.SSO_COOKI
我有一个“保持登录”复选框,所以我使用cookie来实现它,但我的问题是,我有两个链接要注销,当我单击每个链接时,我不会被重定向到登录页,因为在日志页面加载时,我正在测试cookie是否已满,并且始终是满的。因为注销的时候我不能清理饼干..。我试着从后端调用一个函数来清除cookie,但是它没有启动,所以你能帮我吗?
Protected Sub btn_login_Click(sender As Object, e As System.EventArgs) Handles btn_login.Click
If Session("valid") Then
我有一个cookie,可以存在于这两个域中的任何一个-- www.xyz.com或.xyz.com。我在通过代码删除cookie时遇到了问题。由于它可以存在于这两个域中的任何一个域中,我假设执行以下操作就足够了:
...
cookies.delete cookie #delete cookie if it exists on current domain(www.xyz.com)
cookies.delete cookie, :domain => :all #delete cookie if it exists on root (.xyz.com)
...
但是cookies.dele