Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71130 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50008 invoked from network); 15 Jan 2014 00:54:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Jan 2014 00:54:38 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.48 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.215.48 mail-la0-f48.google.com Received: from [209.85.215.48] ([209.85.215.48:64483] helo=mail-la0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2B/E0-44324-C4CD5D25 for ; Tue, 14 Jan 2014 19:54:37 -0500 Received: by mail-la0-f48.google.com with SMTP id er20so903498lab.35 for ; Tue, 14 Jan 2014 16:54:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=k4EUdVSmDbrM7+cKnJ7SePryCJMYrmtH5i+Akq1V998=; b=f4u2LfvaWxaSpuZdPo42BtoDGXyHyrtIG9ZRfGGKeV+hpOzZxCxZlGEBGiZyqhVqae WZCYRnVhnPkcw/pbDVJZFLTptXSqAv2qtDfTykNHIkp9I+ToqI17H2ouGdtn2tF9rdrp g2o1oMLzH5GGhxYQT5V2Nj2EFqMha5325Uo12z8FYrp2SU1PvX77mw23Wn+j48E2kEh2 5WIYjruWypeXT3cMszaeiRI7Vaxhip4dUhOq6z8lUUalCRU87qQho6WDfY4nCbrIG6aR Oe3Gee5DeZasK+O7AHw4HpDEYGXtI7DGNyyorwgZfeR7iLcmuKsVk1UIea5Bdbnw0Qa1 x8Mw== X-Received: by 10.152.115.130 with SMTP id jo2mr2552243lab.2.1389747272929; Tue, 14 Jan 2014 16:54:32 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.6.68 with HTTP; Tue, 14 Jan 2014 16:53:52 -0800 (PST) Date: Wed, 15 Jan 2014 09:53:52 +0900 X-Google-Sender-Auth: EWVxk9ci-OtDpdRtpfia1nd7RLo Message-ID: To: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c2260287d65404eff7c011 Subject: CGI SAPI is sending multiple set-cookie headers when session strict mode is on From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c2260287d65404eff7c011 Content-Type: text/plain; charset=UTF-8 Hi all, CGI SAPI is sending multiple set-ccokie headers when strict mode is on. [yohgaki@dev test-php-script]$ php-cgi session-strict-mode.php X-Powered-By: PHP/5.5.7 Set-Cookie: PHPSESSID=semtekrsf2l13svihttdgo4hg4; path=/ Set-Cookie: PHPSESSID=vkh55u82icdq80p3i4v3831kc2; path=/ while CLI server and Apache SAPI does not. Current php_session_initialize() is 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 */ /* php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Failed to read session data: %s (path: %s)", PS(mod)->s_name, PS(save_path)); */ } I've coded above since I cannot change 3rd party session save handler's code. It is better to write as follows (and change PS(session_status) in session read). /* 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 */ /* 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(session_status) != php_session_active) { php_session_reset_id(TSRMLS_C); PS(session_status) = php_session_active; } Session module code could be changed so that it will not try to set multiple set-cookie headers and works with unmodified 3rd party save handlers. Alternatively, I suppose CGI SAPI could be changed, since CLI server and Apache SAPI does not send multiple set-cookie headers. There are many SAPIs, so I'm wondering which is the best way to fix this issue. Comments are appreciated. Thank you. Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11c2260287d65404eff7c011--