Hide form fields:
Hidden fields are invisible elements that are used to collect or send information, and hidden fields are invisible to visitors to a Web page. When a form is submitted, the hidden field sends the information to the server with the name and value that you defined when you set it.
Code format:
Attribute Explanation:
Type= "hidden" to define hidden fields;
The name attribute defines the names of hidden fields, and to ensure accurate data acquisition, a unique name must be defined;
The Value property defines the values of the hidden fields
Example:
In fact, the hidden domain is not visible in the foreground, as the elements of the form. There is a name with a value, just in the submission of the data is invisible
In fact, that is, from the table value ID value, or other variable value, but not displayed in the page, and then through the <form Action=xx.asp> submitted to a new page, through the Request.Form ("Hidden domain name") to take out the value.
Such as:
1, <input Type=hidden Name=coun value=<%=cc%>>
The hidden domain name here is Coun, the value is <%=cc%>, assuming the previous cc=100, that is, the value is 100;
2, submit the form <form action=xx.asp> to the new page xx.asp;
3. In the Xx.asp page, using Request.write request.form ("Coun"), the value shown in the page is 100
Such an explanation should be quite clear.
In short, it's
You want to extract some information from the previous page, but those things that don't appear on the previous page are in the Tibetan domain
URL rewriting
URL rewriting is the process of intercepting incoming WEB requests and automatically redirecting requests to other URLs. For example, the browser sends the request hostname/101.html, the server automatically directs this request to http://hostname/list.aspx? id=101.
The advantage of URL rewriting is that:
1, shorten the URL, hide the actual path to improve security.
2, easy to user memory and typing.
3, easy to be indexed by search engines.
Cookies:
In the Web site, the HTTP request is stateless. This means that even after the first connection to the server and the successful logon, the second request server still does not know which user the current request is. The advent of cookies is to solve this problem, the first time the server returns some data (cookies) to the browser, and then the browser is saved locally, when the user sends a second request, it will automatically the last request to store the cookie data automatically carried to the server, The data that the server carries through the browser can tell what the current user is. The amount of data stored by a cookie is limited, and different browsers have different storage sizes, but generally not more than 4KB. Therefore, using cookies can only store small amounts of data.
session:
Sessions and cookies are a bit similar in that they are intended to store user-related information. The difference is thatthecookie is stored in the local browser while the session is stored on the server. The data stored on the server is more secure and not easily stolen. But stored in the server also has a certain disadvantage, is to occupy the resources of the server, but now the server has been developed, some session information is more than enough.
cookies are used in conjunction with session:
The development of web development so far,the use ofcookies and session has emerged some very mature programs. In today's market or enterprise, there are generally two kinds of storage methods:
1, stored on the server: a session_idis stored through a cookie, then the specific data is saved in the session the. If the user is logged in, the server will Save a session_idin the cookie, and the next time the request is made, the session_id carry up, the server according to session_id in the session Library to obtain the user's Session data. To know who the user is, and some of the status information that was previously saved. This professional term is called Server side session.
2, the session Data encryption, and then stored in the cookie . This professional term is called the client side session. This is the way flask is used, but it can be replaced by other forms.
use cookies and session in FlaskOne
Cookies:
in the manipulating cookiesin Flaskis done by response objects and can be response Before returning, set by Response.set_cookie , this method has the following parameters to note:
Key: Set the key of the cookie .
Value:the value corresponding to key.
Max_age: Change The expiration time of the cookie, if not set, the browser will automatically expire when it is closed.
Expires: Expiration time, should be a datetime type.
Domain: The domain name in which the cookie is valid. Sub-domains, such as cms.example.com, are generally set .
Path: The path under which the cookie is valid.
Use:
Get:request.cookies.get (Key, ' default value ')
setting:Resp.set_cookie (key, value, max_age= integer )
Delete:Resp.delete_cookie (Key)
Two
session:
the session in Flask is via the from Flask import session. Then add a value of key and value to go in.
Client Side session:The session mechanism in Flask is to encrypt the session information, It is then stored in a cookie . The jargon is called the client side session.
Server side session: stored on the server, when the client saves the session_id(via cookie )
Use:
Get:session.get (Key, ' default value ')
Set up:
Session.permanent = True
Session[key] = value
Delete:
Specify Delete :session.pop (Key, None)
Clear All :session.clear ()
Hide form fields, url overrides, cookies, session