标签:style http color io os ar for sp div
作者:zhanhailiang 日期:2014-10-20
日常开发中,php.ini配置session.auto_start=0默认关闭会话时如果想开启会话需要调用session_start:
<?php session_start(); //...
通过查到源码,可知session_start定义如下:
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 }
可以看到session_start本质是通过调用php_session_start来开启会话。
如果修改php.ini中session.auto_start=1默认开启session时通过源码可知在RINIT(即请求初始化)中自动调用php_session_start来开启会话:
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 /* }}} */
PHP源码分析之session.auto_start配置分析
标签:style http color io os ar for sp div
原文地址:http://blog.csdn.net/billfeller/article/details/40318419