Home > other >  Some of the Session object
Some of the Session object

Time:04-30

Development tools and key technology: MVC
Sessions and cookies are two important things in network programming, the nature of the Session: equivalent to the class, in the server's memory, each browser to connect to it, he will be assigned to separate a space to store the Session and cookie information, the Session on the server, the cookie in the browser,

Seeion among servers, server: in space, memory area bar, storage in dialogue with it browser information,

The Session object is used to store information about a user Session (Session), or change the Settings, variable stored in the Session object holds the single user information, at the same time, the information is available to all pages in a web page

When you are operating an application, you will start it, and then make some changes, then closed it, the process is like a conversation (Session), the computer knows who you are, it also know you when to start and shut down this application, but the web server does not know who you are, and I don't know what you do, so the ASP for each user to create a unique cookie solves this problem, a cookie is sent to the server, it contains can recognize the user's information, this interface is called the Session object

Seeion among servers, server: in space, memory area bar, storage in dialogue with it browser information,
A, the Session begins?

The Session started in:
1, when a new user requests an ASP file, and Global. The asa file cited Session_OnStart subroutines;
2, when a value stored in the Session variable;
3, when a user requests an ASP file, and Global. Asa use & lt; Object> Tag example shows an object through the scope of the session;

Second, when the Session ends?

1, if the user is not in the application within the stipulated time request or refresh the page, the session will be over, the default value is 20 minutes,
2, if you want to set the Timeout interval longer or shorter, you can set the Timeout attribute,
This example demonstrates "Timeout" attribute, the example set and returns the session Timeout (minutes),

If you want an immediate end to the session, can use Abandon method,
Tip: if you are using a session variable, please don't in which to store large amounts of data,

Three, to store and retrieve the session variable
Session object can store variables, is the biggest advantage for the subsequent pages, its application range is very wide, the information stored in the Session object is usually the name, id and parameters, the server will be for each new user to create a new Session, and upon the expiry of the Session to cancel out the Session object,

* * the following examples to make the "XiaoMing" assigned to the session variable, called the username and "50" assigned to the session variable called age


Four, removing the session variable
Contents collection contains all of the session variable,
Through the remove method to remove the session variable,

* * in the following example, if the value is less than 18 of the session variable "age", "sale" is to remove the session variables:






Do not spray to new, please advice, a great god,
  • Related