About the IIS session _php tutorial

Source: Internet
Author: User
Tags blank page
Session Basic OperationAdd Modify Session Entry Session.add ("Test", DateTime.Now);
session["Test"] = DateTime.Now; the method of adding and modifying the session is the same, and the system is added when the specified session ID does not exist. The system updates when it is present. Delete Session Item Session.remove ("test"); Do not use session["test"] = NULL; This only sets the value to null! Remove all session entries Session.clear (); or Session.removeall (); Terminates the current session state Session.Abandon (); The current number of sessions Session.count current Sessionidsession.sessionid when the session is createdAll browsers (ie, Chrome, Firefox) The server side creates a new session when the browser is opened for the first time (not currently running the browser). Internet Explorer, when a browser is running, opens a new browser and creates a new session. While Chrome and Firefox are running in a browser, opening a new browser does not create a new session. When the session expires, the session is created when you continue to access it. The Session_Start method in Global.asax is triggered when the session is created. when the session expires
    • Code Session.Abandon (); Causes the session to expire.
    • Session timed out, automatic expiration.
    • Web. config is modified and will expire.
    • The application pool for IIS is being recycled.
The Session_End method in Global.asax is triggered when the session expires. Strange question: Session.Abandon (); The effect of automatic expiration with session timeout is the same. Causes the Session_Start and Session_End methods to be executed when the page is refreshed after the expiration. How to avoid adding session["sessionstartdatetime" = DateTime.Now in Session_Start, Session.Abandon in Call (), response.cookies.add after execution (New HttpCookie ("ASP tutorial. Net_sessionid", "")); let SessionID reset. Session Expiration TimeSet in Web. config The minute value. The session timeout setting for IIS is not effective (default is 20 minutes when not filled in). (set location such as) the collection time limit for the application pool that is associated with the site. The test is not effective. However, it works if you manually recycle or set up a timed collection. (How to associate a site application pool, for example) how to prevent the session from expiringYou can set a longer session expiration time. However, setting too long may cause the server to be overburdened. Set the session mode to out-of-process or database tutorials. No discussion will be made here. The general reality may be that users on certain pages, such as the blog post submission page, are in the process of editing because it takes a long time. The session may be found to be out of date at the time of submission. The article is not submitted because the user information is lost. If this is the case, you may want to extend the session time for the specified page only. A blank page in the background can be accessed periodically via Ajax. To keep the session online. Create an empty page updatesession.aspx Note Add note in Page_Load when Ajax requests an ASPX page, the ASPX page should be set to disallow caching! protected void Page_Load (object sender, EventArgs e)
{
Response.appendheader ("Pragma", "no-cache");
Response.appendheader ("Cache-control", "No-cache, must-revalidate");
Response.appendheader ("Expires", "0");
} about SessionIDWhen the session expires, SessionID does not change. Call Response.Cookies.Add (New HttpCookie ("ASP. _sessionid", "")); Can be set SessionID when set to NULL, the server side creates a new session. And the old session was not released. When set to another existing SessionID value, the session at this time gets the specified session. This is Session HijackingThe how to count the current site session number. Create a Class View Sourceprint?
publicclassconstants
{
///
/// 当前session个数
///
publicstatic intsessioncount = 0;
///
/// 累计session个数
///
publicstatic intsessionallcount = 0;
}
Add view Sourceprint in Global.asax?
voidsession_start(objectsender, eventargs e)
{
constants.sessionallcount++;
constants.sessioncount++;
session["sessionstartdatetime"] = datetime.now;
}
voidsession_end(objectsender, eventargs e)
{
constants.sessioncount--;
}

http://www.bkjia.com/PHPjc/444796.html www.bkjia.com true http://www.bkjia.com/PHPjc/444796.html techarticle Session Basic Operation Add Modify session Item Session.add (test, DateTime.Now); session[test] = DateTime.Now; Add and modify session methods are the same, When the specified session ID does not exist ...

  • 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.