Session.auto_start Configuration Analysis of PHP source code analysis

Source: Internet
Author: User

  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:

<?php 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) {1889Return_false;1890         }1891return_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 Staticphp_rinit_function(Session) /* {{{ */2130 {2131php_rinit_session_globals(Tsrmls_c);2132 2133 +-----  8Lines: if (PS(MoD) ==NULL) {----------------------------------------------------------------------------------------------------------- ---------------------2141                 2142 +-----  8Lines: if (PS(Serializer) ==NULL) {---------------------------------------------------------------------------------------------------------- ---------------2150                 2151 +-----  5Lines: if (PS(MoD) ==NULL||PS(Serializer) ==NULL) {------------------------------------------------------------------------------------------------------2156                         2157         if (PS(Auto_start)) {2158                 Php_session_start(Tsrmls_c);2159         }2160 2161         returnSUCCESS;2162 }2163 /* }}} */

Session.auto_start Configuration Analysis of PHP source code analysis

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.