Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96533 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14199 invoked from network); 21 Oct 2016 02:51:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Oct 2016 02:51:59 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@ohgaki.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@ohgaki.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ohgaki.net designates 180.42.98.130 as permitted sender) X-PHP-List-Original-Sender: yohgaki@ohgaki.net X-Host-Fingerprint: 180.42.98.130 ns1.es-i.jp Received: from [180.42.98.130] ([180.42.98.130:48113] helo=es-i.jp) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9C/1E-24564-AC289085 for ; Thu, 20 Oct 2016 22:51:58 -0400 Received: (qmail 31892 invoked by uid 89); 21 Oct 2016 02:51:50 -0000 Received: from unknown (HELO mail-qk0-f182.google.com) (yohgaki@ohgaki.net@209.85.220.182) by 0 with ESMTPA; 21 Oct 2016 02:51:50 -0000 Received: by mail-qk0-f182.google.com with SMTP id o68so128201958qkf.3 for ; Thu, 20 Oct 2016 19:51:49 -0700 (PDT) X-Gm-Message-State: ABUngvfegxayEiN9/qg7nNIEoRL7scZeb568ejkct/uWBz0AVuYkvuBJ04PHdOGSG0QUHkjS9sGhDaIyZwXvgQ== X-Received: by 10.55.102.17 with SMTP id a17mr3333066qkc.17.1477018303771; Thu, 20 Oct 2016 19:51:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.22.38 with HTTP; Thu, 20 Oct 2016 19:51:03 -0700 (PDT) In-Reply-To: References: <1eab7492-596c-ffd2-81ed-0eb9256a033e@gmail.com> <0B722A15-A29F-498B-987F-F6BA5AA49EEF@bobs-bits.com> <59D6B40B-DC64-43A3-AED4-CD5C9C15B6BA@koalephant.com> Date: Fri, 21 Oct 2016 11:51:03 +0900 X-Gmail-Original-Message-ID: Message-ID: To: Niklas Keller Cc: Stephen Reay , Stanislav Malyshev , "internals@lists.php.net" , Davey Shafik , Xinchen Hui Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] header() removes all header of the same name. From: yohgaki@ohgaki.net (Yasuo Ohgaki) On Fri, Oct 21, 2016 at 9:35 AM, Yasuo Ohgaki wrote: > On Thu, Oct 20, 2016 at 9:21 PM, Niklas Keller wrote: >> Before we even discuss disallowing `header("set-cookie")`, we should have a >> sane cookie API, e.g. one that like `setcookie($name, $value, $flags)`. >> >> That's also the way we implemented it in Aerys >> (https://github.com/amphp/aerys/blob/9a7327f062aa678408dfe4f4c3c7f479db16f187/lib/Response.php#L49-L58). >> It's a simple wrapper around `addHeader` to make life easier, but it doesn't >> restrict developers to call `setHeader` and replace all `set-cookie` >> headers. > > We choose current API for reason. It does not look pretty. > This is patch allow array config for 3rd param for setcookie(). > > https://gist.github.com/yohgaki/b86e07cd450777422c1a467166cd2fd3 > > I suppose some of us will have opinions having this kind of code(s). > > Any comments? Execution example. [yohgaki@dev github-php-src]$ cat t13.php 1, 'path'=>'foo', 'expires'=>time()+999, 'secure'=>1, 'domain'=>'example.com']); setcookie('A', 'B', ['httponly'=>1] ); setcookie('A', 'B', 999); setcookie('A', 'B', time()+999); echo 'OK'; [yohgaki@dev github-php-src]$ ./php-cgi t13.php X-Powered-By: PHP/7.2.0-dev Set-Cookie: A=B; expires=Fri, 21-Oct-2016 02:55:31 GMT; Max-Age=999; path=foo; domain=example.com; secure; HttpOnly Set-Cookie: A=B; HttpOnly Set-Cookie: A=B; expires=Thu, 01-Jan-1970 00:16:39 GMT; Max-Age=-1477016533 Set-Cookie: A=B; expires=Fri, 21-Oct-2016 02:55:31 GMT; Max-Age=999 Content-type: text/html; charset=UTF-8 OK If PHP has named parameter, we don't need this patch. Dose anyone working on named parameter? One issue of this patch is strict types. It ruins strictly typed parameter because array option parameters won't be checked by PHP. -- Yasuo Ohgaki yohgaki@ohgaki.net