webform--Second Lecture

Source: Internet
Author: User
Tags sessions

All Web programs are stateless.
Cause: The HTTP transport protocol they use is itself a stateless protocol.
Performance: Each page returned to the customer is unrelated to the previous or subsequent page, unable to access the data on the previous page, or sending data for subsequent pages.
Workaround: Data that is specifically stored on the server side or client by using several objects to store the relevant state.

State objects stored on the service side
Session:
Each stand-alone browser creates a separate session, not a single computer session.
The data stored by the session is shared in the current session.
Session will be released automatically within 20 minutes if there are no sessions.
Grammar:
1. Save value by Session: session["key Name"] = value; Value, which is not just a string, it can be an object.
2. Value from Session: type variable name = (cast type name) session["key Name"]
3. Determine if a value exists in the session

4. Release session
Release a session:session["key name"] = NULL;
Releases all the Session:Session.Clear () in the session;
Automatic release: 20 minutes

Case:
1. Login: Prevent bypassing the login interface.


2. Log in: Remember the user name. Show "Welcome you: Username" on each interface

Application
All sessions share a application space, and anyone who changes the content in the applciation will find it changed.
The data in the application is not automatically freed.
1. Application value: application["key Name"] = value; Value, which is not just a string, it can be an object.
2. Value from application: Type variable name = (cast type name) application["key Name"]
3. Determine if a value exists in the application
if (application["key Name"] = = null)
{

}
4. Release application:application["key name"] = NULL;

State objects stored on the client (on the hard disk):
Cookies
Stored on the client's memory or hard disk.
A temporary cookie is present in the browser memory. Persistent cookies are found in the browser-related cookie directory on the hard disk.

Set cookies
response.cookies["key Name"]. Expires = Expiration time.
response.cookies["key Name"]. Value = values.

Read cookies
string s = request.cookies["key Name"]. ToString ();

Will write a temporary cookie, a persistent cookie, a cookie will be read, and a cookie will be deleted.

Log in with a cookie



webform--Second lecture

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.