方法一:
无论何时你在两页之间,有一个非常简单可靠的方法:请求一个SessionID在第一页,传递它到下一页。与这一页请求到的SessionID比较。相同说明客户端浏览器接受Cookies;不同则不接受。很简单吧。
比如你可以在第一页中放一个(hidden field),并把SessionID写入它。提交后,从页面数据中取出SessionID.像这样:
<
form name
=
"
Form1
"
method
=
"
post
"
action
=
"
sessions2.asp
"
>
UserName:
<
input name
=
"
username
"
><
br
>
Password:
<
input name
=
"
userpassword
"
>
<
input type
=
"
hidden
"
name
=
"
theSessionID
"
value
=
"
<%=Session.SessionID%>
"
><
br
>
<
input type
=
"
submit
"
value
=
"
Submit
"
>
</
form
>
在第二页中我们来判断SessionID是否相同。
<%
dim theSessionID
theSessionID
=
Request.Form(
"
theSessionID
"
)
If theSessionID
=
Session.SessionID Then
"
当二者相等时,则cookie功能开启
Response.Write
"
Cookie已开启
"
Else
"
若二者相等时,则cookie功能关闭
Response.Write
"
Cookie没有开启!
"
End If
%>
方法二:
也可用这种方法,首先在一个页面里写入一个cookie,如:
<%
Response.Cookies(
"
status
"
)
=
"
onoroff
"
%>
在第二页里读出此cookie:
<%
if
Request.Cookies(
"
status
"
)
=
""
then
"
当cookies(
"
status
"
)里没有值时,则cookie功能没有开启
Response.Write
"
Cookie没有开启!
"
else
"
当cookies(
"
status
"
)里有值时,则cookie功能开启
Response.Write
"
Cookie已开启
"
end
if
%>