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/*}}} */