Session.auto_start Configuration Analysis of PHP source code analysis

Source: Internet
Author: User
Tags php source code
  Author: zhanhailiang Date: 2014-10-20

Application analysis

In daily development, the php.ini configuration session.auto_start=0 closes the session by default if you want to open the session to call Session_Start:

   

Kernel analysis

By checking the source code, we know that session_start is defined as follows:

1881/* {{proto bool Session_Start (void) 1882 Begin session-reinitializes freezed variables, registers browsers etc */ 1883 Static php_function (Session_Start) 1884 {1885         */skipping check for Non-zero args for performance reasons here? */ 1886         Php_session_start (Tsrmls_c); 1887 1888         if (PS (session_status)! = php_session_active) {1889                 Return_ false;1890         }1891         return_true;1892}

You can see that the Session_Start essence is to open the session by calling Php_session_start.

If you modify the php.ini in Session.auto_start=1 by default when the session is opened by the source, the Rinit (that is, request initialization) automatically calls Php_session_start to open the conversation:

2129 Static Php_rinit_function (session)/* {{{*/2130 {2131         php_rinit_session_globals (tsrmls_c); 2132 2133 +-----  8 lines:if (PS (mod) = = NULL) {-------------------------------------------------------------------------------- ------------------------------------------------2141                 2142 +-----  8 Lines:if (PS (serializer) = = NULL) {------ --------------------------------------------------------------------------------------------------------------- ----2150                 2151 +-----  5 lines:if (PS (mod) = = NULL | | PS (Serializer) = = NULL) {---------------------------------------------------------------------------------------- --------------2156                         2157         if (PS (Auto_start)) {2158                 php_session_start (tsrmls_c); 2159         }2160 2161         return success;2162}2163/*}}} */
  • 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.