Session, phpsession

Source: Internet
Author: User

Session, phpsession
ASP. NET session time settings
Method 1:

The default asp.net Session time is set to 20 minutes. That is, after 20 minutes, the server automatically discards the Session information.

When we open webconfig in the asp.net program, we can see the following code: Asp.net program code: <sessionState
Mode = "InProc"
StateConnectionString = "tcpip = 127.0.0.1: 42424"
SqlConnectionString = "data source = 127.0.0.1; Trusted_Connection = yes"
Cookieless = "false"
Timeout = "20"
/> The above Code is to configure how the application stores Session information. timeout = "20" indicates the default time of the asp.net session. we need to change the time by entering different values here. The default unit is minute.


SessionState node attributes:

<SessionState mode = "Off | InProc | StateServer | SQLServer"
Cookieless = "true | false"
Timeout = "number of minutes"
StateConnectionString = "tcpip = server: port"
SqlConnectionString = "SQL connection string"
StateNetworkTimeout = "number of seconds"
/>

The required attribute is

Mode setting: Where to store Session information
Off is set to not use the Session Function
InProc is set to store sessions in the process, which is the storage method in ASP. This is the default value.
StateServer is set to store sessions in independent State services.
SQLServer settings store sessions in SQL Server

Optional attributes:
Cookieless sets where the Session information of the client is stored
Ture uses Cookieless Mode
False uses Cookie mode, which is the default value.
Timeout specifies the number of minutes after which the server automatically waives the Session information. The default value is 20 minutes.
StateConnectionString sets the server name and port number used by Session information stored in the status service, for example, "tcpip = 127.0.0.1: 42424 ". This attribute is required when the mode value is StateServer.
SqlConnectionString sets the connection string when connecting to SQL Server. This attribute is required when the mode value is SQLServer.
StateNetworkTimeout sets the number of seconds after the Session state is stored in StateServer mode and the TCP/IP connection between the Web server and the server that stores the status information. The default value is 10 seconds.

ASP. NET session time setting method 2:However, sometimes modifying the configuration file cannot solve this problem.

You can modify it in Global. asax in the public program. We can find Session_Start in global. asax and set it as follows.

Void Session_Start (object sender, EventArgs e)
{
// The code that runs when the new session starts
Session. Timeout = 600;
}

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.