]> granicus.if.org Git - php/commitdiff
Fixed session module is sending multiple set-cookie headers when session.use_strict_m...
authorYasuo Ohgaki <yohgaki@php.net>
Wed, 15 Jan 2014 02:03:07 +0000 (11:03 +0900)
committerYasuo Ohgaki <yohgaki@php.net>
Wed, 15 Jan 2014 02:06:06 +0000 (11:06 +0900)
NEWS
ext/session/mod_files.c
ext/session/mod_mm.c
ext/session/session.c

diff --git a/NEWS b/NEWS
index ae9bd7259bfac45af26d959915e0fca3a49f4b14..5564c07e2d25c907fc5d0db3047f6019b1495a91 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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)
 
index c365760eb7583f0a2a15323672bfd4f28f5a5a03..4d5a18b36be5f27db1192d1ff5beae2ced5bafc4 100644 (file)
@@ -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);
index 41df247e745dfa9e2dd54c9ec6fa038d62e890a4..319f1d3c790acc888a203aa833be1a04c41f69b3 100644 (file)
@@ -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);
index c579f1b83b74b40720900c10f0a55cda2846ad6f..c1bdf83633fb1fb57480989e4c83e23b23393549 100644 (file)
@@ -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);