Skip to content

Commit

Permalink
Fixed session module is sending multiple set-cookie headers when sess…
Browse files Browse the repository at this point in the history
…ion.use_strict_mode=1
  • Loading branch information
Yasuo Ohgaki committed Jan 15, 2014
1 parent 9c32d30 commit f52c251
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ PHP NEWS
. Fixed bug #66298 (ext/opcache/Optimizer/zend_optimizer.c has dos-style
^M as lineend). (Laruence)

- Session
. Fixed session module is sending multiple set-cookie headers when
session.use_strict_mode=1 (Yasuo)

- Standard
. Fixed bug #66395 (basename function doesn't remove drive letter). (Anatol)

Expand Down
1 change: 1 addition & 0 deletions ext/session/mod_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ PS_READ_FUNC(files)
PS(send_cookie) = 1;
}
php_session_reset_id(TSRMLS_C);
PS(session_status) = php_session_active;
}

ps_files_open(data, PS(id) TSRMLS_CC);
Expand Down
1 change: 1 addition & 0 deletions ext/session/mod_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ PS_READ_FUNC(mm)
PS(send_cookie) = 1;
}
php_session_reset_id(TSRMLS_C);
PS(session_status) = php_session_active;
}

sd = ps_sd_lookup(data, PS(id), 0);
Expand Down
14 changes: 11 additions & 3 deletions ext/session/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,18 +492,26 @@ static void php_session_initialize(TSRMLS_D) /* {{{ */
}
}

php_session_reset_id(TSRMLS_C);
PS(session_status) = php_session_active;
/* 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;
}

/* Read data */
php_session_track_init(TSRMLS_C);
if (PS(mod)->s_read(&PS(mod_data), PS(id), &val, &vallen TSRMLS_CC) == FAILURE) {
/* Some broken save handler implementation returns FAILURE for non-existent session ID */
/* It's better to rase error for this, but disabled error for better compatibility */
/* It's better to raise error for this, but disabled error for better compatibility */
/*
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Failed to read session data: %s (path: %s)", PS(mod)->s_name, PS(save_path));
*/
}
/* Set session ID if session read didn't activated session */
if (PS(use_strict_mode) && PS(session_status) != php_session_active) {
php_session_reset_id(TSRMLS_C);
PS(session_status) = php_session_active;
}
if (val) {
php_session_decode(val, vallen TSRMLS_CC);
efree(val);
Expand Down

0 comments on commit f52c251

Please sign in to comment.