PHP source code analysis-session. auto_start configuration analysis

Source: Internet
Author: User
PHP source code analysis-session. auto_start configuration analysis
Author: zhanhailiang date:

Application Analysis

In daily development, if session. auto_start = 0 is configured in php. ini by default, session_start must be called to enable the session:

   

Kernel analysis

By checking the source code, we can see 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}

The essence of session_start is to enable the session by calling php_session_start.

If session. auto_start = 1 in php. ini is enabled by default, php_session_start is automatically called in RINIT (Request Initialization) by the source code to enable the session:

2129 static PHP_RINIT_FUNCTION (session)/* {*/2130 {2131 php_rinit_session_globals (TSRMLS_C); 2132 2133 + ----- 8 lines: if (PS (mod) = NULL) {queue-2141 2142 + ----- 8 lines: if (PS (serializer) = NULL) {queue 2150 2151 + ----- 5 lines: if (PS (mod) = NULL | PS (serializer) = NULL) {limit 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.