ASP如何读取javascript设置的COOKIES值
ASP如何读取javascript设置的COOKIES值呢
我用以下函数在客户端进行写操作
function wcookies(name, value, seconds)
{
var expire = " ";
if(seconds)
{
expire = new Date((new Date()).getTime() + seconds * 1000);
expire = "; expires= " + expire.toGMTString();
}
document.cookie = name + "= " + escape(value) + expire;
}
但发现用Request.Cookies( "Keyv ") 取不到值,是怎么回事,要怎么搞才行。
------解决方案--------------------鍦ㄥ啓涔嬪悗鍙互璇诲埌锛屾祴璇曚唬鐮?
<%
response.write request.cookies( "Keyv ")
%>
<script>
function wcookies(name, value, seconds)
{
var expire = " ";
if(seconds)
{
expire = new Date((new Date()).getTime() + seconds * 1000);
expire = "; expires= " + expire.toGMTString();
}
document.cookie = name + "= " + escape(value) + expire;
}
wcookies( "Keyv ", "123 ",500);
</script>
------解决方案--------------------宸叉祴寮忥紝鍙互鐨勶紝浠g爜娌¢棶棰橈紝鎵炬壘鍏跺畠鍘熷洜锛?
t.html
------------------------------------
<script>
function wcookies(name, value, seconds)
{
var expire = " ";
if(seconds)
{
expire = new Date((new Date()).getTime() + seconds * 1000);
expire = "; expires= " + expire.toGMTString();
}
document.cookie = name + "= " + escape(value) + expire;
}
wcookies( "testname ", "testvalue ",100);
</script>
t.asp
---------------------------------------------------
<% @ language= "vbscript " %>
<% Response.Expires = -1 %>
<%=Request.Cookies( "testname ")%>
------解决方案--------------------加一个path属性
path=/;expire=...;