以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  后台设置的cookie,前端js怎么删啊  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=159370)

--  作者:cyl123
--  发布时间:2020/12/23 22:04:00
--  后台设置的cookie,前端js怎么删啊
后台e.Appendcookie 设置的cookie,前端js究竟怎么删啊?

怎么都删不掉  ,都试试过了,https://www.cnblogs.com/endv/p/8089506.html

function delCookie(name)
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null)
document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}




--  作者:yjf123
--  发布时间:2020/12/24 9:05:00
--  

--  作者:有点蓝
--  发布时间:2020/12/24 9:55:00
--  
测试没有问题

js文件

function getCookie(name)
{
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}

function delCookie(name)
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null)
document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}

httprequest
Dim cnt As  Integer = 1
Integer.TryParse(e.Cookies("count"),cnt) \'提取cookie的值, 并转换为整数
cnt = cnt + 1
e.AppendCookie("count",cnt) \'在客户端存储Cookie
Dim sb As New StringBuilder
    sb.appendLine("<!doctype html>")
    sb.appendLine("<html>")
    sb.appendLine("<head>")
    sb.appendLine("<meta charset=\'utf-8\'>")
    sb.appendLine("<title>表单</title>")
    sb.appendLine("</head>")
    sb.appendLine("<body>")
sb.AppendLine("<input Type=\'button\' name=\'Sumbit\' id=\'Sumbit\' value=\'确定\' onclick=\'delCookie(""count"")\'>")
    sb.appendline("<script src=\'./lib/ajx.js\'></script>") \'引入脚本文件
    sb.appendLine("</body>")
    sb.appendLine("</html>")
e.WriteString(sb.ToString)
[此贴子已经被作者于2020/12/24 9:55:58编辑过]