}
/* }}} */
- nrand = (int) ((float) PS(gc_divisor) * php_combined_lcg(TSRMLS_C));
+
+ static void php_session_gc(void) /* {{{ */
+ {
+ int nrand;
+
+ /* GC must be done before reading session data. */
+ if ((PS(mod_data) || PS(mod_user_implemented)) && PS(gc_probability) > 0) {
+ int nrdels = -1;
+
- PS(mod)->s_gc(&PS(mod_data), PS(gc_maxlifetime), &nrdels TSRMLS_CC);
++ nrand = (int) ((float) PS(gc_divisor) * php_combined_lcg());
+ if (nrand < PS(gc_probability)) {
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "purged %d expired session objects", nrdels);
++ PS(mod)->s_gc(&PS(mod_data), PS(gc_maxlifetime), &nrdels);
+ #ifdef SESSION_DEBUG
+ if (nrdels != -1) {
-static void php_session_initialize(TSRMLS_D) /* {{{ */
++ php_error_docref(NULL, E_NOTICE, "purged %d expired session objects", nrdels);
+ }
+ #endif
+ }
+ }
+ } /* }}} */
+
+
+static void php_session_initialize(void) /* {{{ */
{
- char *val = NULL;
- int vallen;
+ zend_string *val = NULL;
if (!PS(mod)) {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "No storage module chosen - failed to initialize session");
+ php_error_docref(NULL, E_ERROR, "No storage module chosen - failed to initialize session");
return;
}
if (PS(use_cookies)) {
PS(send_cookie) = 1;
}
+ } else if (PS(use_strict_mode) && PS(mod)->s_validate_sid &&
+ PS(mod)->s_validate_sid(&PS(mod_data), PS(id)) == FAILURE) {
+ if (PS(id)) {
+ zend_string_release(PS(id));
+ }
+ PS(id) = PS(mod)->s_create_sid(&PS(mod_data));
+ if (!PS(id)) {
+ PS(id) = php_session_create_id(NULL);
+ }
+ if (PS(use_cookies)) {
+ PS(send_cookie) = 1;
+ }
}
- /* Set session ID for compatibility for older/3rd party save handlers */
- if (!PS(use_strict_mode)) {
- php_session_reset_id(TSRMLS_C);
- PS(session_status) = php_session_active;
- }
+ php_session_reset_id();
+ PS(session_status) = php_session_active;
+ /* GC must be done before read */
+ php_session_gc();
+
/* Read data */
- php_session_track_init(TSRMLS_C);
- if (PS(mod)->s_read(&PS(mod_data), PS(id), &val, &vallen TSRMLS_CC) == FAILURE) {
+ php_session_track_init();
+ if (PS(mod)->s_read(&PS(mod_data), PS(id), &val, PS(gc_maxlifetime)) == FAILURE) {
/* Some broken save handler implementation returns FAILURE for non-existent session ID */
/* It's better to raise error for this, but disabled error for better compatibility */
/*
}
/* }}} */
-PHPAPI void php_session_start(TSRMLS_D) /* {{{ */
+PHPAPI void php_session_start(void) /* {{{ */
{
- zval **ppid;
- zval **data;
+ zval *ppid;
+ zval *data;
char *p, *value;
- int nrand;
- int lensess;
-
- if (PS(use_only_cookies)) {
- PS(apply_trans_sid) = 0;
- } else {
- PS(apply_trans_sid) = PS(use_trans_sid);
- }
+ size_t lensess;
switch (PS(session_status)) {
case php_session_active:
PS(id) = NULL;
}
- /* GC must be done before reading session data. */
- if ((PS(mod_data) || PS(mod_user_implemented)) && PS(gc_probability) > 0) {
- int nrdels = -1;
-
- nrand = (int) ((float) PS(gc_divisor) * php_combined_lcg());
- if (nrand < PS(gc_probability)) {
- PS(mod)->s_gc(&PS(mod_data), PS(gc_maxlifetime), &nrdels);
- #ifdef SESSION_DEBUG
- if (nrdels != -1) {
- php_error_docref(NULL, E_NOTICE, "purged %d expired session objects", nrdels);
- }
- #endif
- }
- }
-
-- php_session_initialize(TSRMLS_C);
-- php_session_cache_limiter(TSRMLS_C);
++ php_session_initialize();
++ php_session_cache_limiter();
}
/* }}} */