Judging whether the cookies are in turn on

zhaozj2021-02-16  55

The client browser must be required to accept cookies when developers use the session variable, when the ASP starts a session, which will give a cookies to the client and bring a sign (sessionid). With this indication, the ASP will confirm the session after the ASP Therefore, it is maintained. So, when you use the session variable, you need to confirm whether the cookies are accepted. Here I explain two methods:

Method 1: Whenever you are between the two pages, there is a very simple and reliable way: ask a sessionID on the first page to pass it to the next page. SESSIONID comparisons with this page. The same explains that the client browser accepts cookies; different will not be accepted. Very simple. For example, you can put a hidden field in the first page and write the sessionid into it. After submit, remove the sessionID from the page data. Like this:

username:
password: in the second page we judge SESSIONID Whether it is the same. <% Dim ThestionidTheSessionID = Request.form ("" "Thesis) if thessionid = session.SessionId Then" When the two are equal, the cookie function turns on the response.write "Cookie" Else "If the two is equal, the cookie function Close Response.write "cookie is not open!" END IF%>

Method 2: You can also use this method, first write a cookie in a page, such as: <% response.cookies ("status") = "onoroff"%> Read this cookie: <% IF in the second page Request.cookies ("status") = "" "When there is no value in cookies (" status ", the cookie function does not open response.write" cookie is not open! "Else" When the cookies ("status") When the value is value, the cookie function opens response.write "cookie has enabled" end if% "

- In addition, I am studying ASP technology

- I hope that friends who learn ASP technology contact me.

-QQ: 7462792

-http://www.xzsky.com

转载请注明原文地址:https://www.9cbs.com/read-23964.html

New Post(0)