-
JScript code
-
function setCookie(c_name,value,expiredays) { var exdate = new Date() exdate.setDate(exdate.getDate() + expiredays) document.cookie = c_name + " = " + escape(value) + " ;path=/ " + ((expiredays == null ) ? "" : " ;expires= " + exdate.toGMTString()) } setCookie( " _cookie " , " 1,2,3,4 " , 5 );
-
C# code
-
Request.Cookies[ " faitem " ].Expires = DateTime.Now.AddDays( - 1.0 );
请问这么在后台删除js设置的cookie值.就是设置他已经过期.
-------------------------------------------------
Request.Cookies["faitem"].Expires = DateTime.Now.AddDays(-1.0);
这样不就可以了吗
Request.Cookies["faitem"].Expires = DateTime.Now.AddDays(-1);
就行了
------------------------------------------------
这样不行呀,我在地址栏上输入javascript:alert(document.cookie)
还是能看到cookie值
----------------------------------------------------
-
C# code
-
Response.Cookies[ " faitem " ].Expires = DateTime.Now.AddDays( - 1 );成功 Response.Cookies.Remove( " faitem " ); Response.Cookies.Clear();
--------------------------------------------------------
哪你Cookie路径什么的设置的是相同的吗?---------------------------------------------------if (Request.Cookies["name"] != null)
{
HttpCookie myCookie = new HttpCookie("name");
myCookie.Expires = DateTime.Now.AddDays(-10);
Response.Cookies.Add(myCookie);
}----------------------------------------------------------JScript code function setCookie(c_name,value,expiredays) { var exdate = new Date() exdate.setDate(exdate.getDate() + expiredays) document.cookie = c_name + " = " + escape(value) + " ;path=/ " + ((expiredays == null ) ? "" : " ;expires= " + exdate.toGMTString()) }
路径 ?"path=/" 这个东西?----------------------------------
在后台删除cookies