Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99908 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68570 invoked from network); 18 Jul 2017 17:20:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jul 2017 17:20:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=michal@brzuchalski.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=michal@brzuchalski.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain brzuchalski.com designates 188.165.245.118 as permitted sender) X-PHP-List-Original-Sender: michal@brzuchalski.com X-Host-Fingerprint: 188.165.245.118 ns220893.ip-188-165-245.eu Received: from [188.165.245.118] ([188.165.245.118:53828] helo=poczta.brzuchalski.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DF/2C-02884-9634E695 for ; Tue, 18 Jul 2017 13:20:42 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id C115329842D3 for ; Tue, 18 Jul 2017 19:20:37 +0200 (CEST) Received: from poczta.brzuchalski.com ([127.0.0.1]) by localhost (poczta.brzuchalski.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YIBNlNFym-o3 for ; Tue, 18 Jul 2017 19:20:30 +0200 (CEST) Received: from mail-wr0-f174.google.com (unknown [209.85.128.174]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id DEFBF29842D0 for ; Tue, 18 Jul 2017 19:20:29 +0200 (CEST) Received: by mail-wr0-f174.google.com with SMTP id y43so38480836wrd.3 for ; Tue, 18 Jul 2017 10:20:29 -0700 (PDT) X-Gm-Message-State: AIVw1129LDPhqe5rdpnAyahZNbR+aO7Wc/hrni34EhE+ucdGfrAeU3Vx C9Vb1InEZNuQ/moKO/NEwz63G1Wzxw== X-Received: by 10.223.179.67 with SMTP id k3mr1820951wrd.198.1500398429605; Tue, 18 Jul 2017 10:20:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.155.194 with HTTP; Tue, 18 Jul 2017 10:20:29 -0700 (PDT) In-Reply-To: <86.8B.02884.8D93E695@pb1.pair.com> References: <64.32.02884.7983D695@pb1.pair.com> <86.8B.02884.8D93E695@pb1.pair.com> Date: Tue, 18 Jul 2017 19:20:29 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Andreas Treichel Cc: PHP Internals List Content-Type: multipart/alternative; boundary="94eb2c1b45026b20a805549abb32" Subject: Re: [PHP-DEV] http_cookie_set and http_cookie_remove From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --94eb2c1b45026b20a805549abb32 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Andreas, 2017-07-18 18:39 GMT+02:00 Andreas Treichel : > Hello Andrey, > > $options are equal to the optional parameters of setcookie and >>> setrawcookie. >>> $options may contain: >>> >>> expires: int >>> path: string >>> domain: string >>> secure: bool >>> httponly: bool >>> >> > 1. The wording here implies that these are the *only* attributes >> allowed. In the interest of forward-compatibility, I'd allow arbitrary >> attributes as well. >> > > This are the only supported options in the current implementation. Future > extension like samesite cookies can add more options. Unknown options are > ignored and trigger a warning. > > > encode is an additional option to remove the requirement of a raw and non >>> raw function. >>> >>> encode: int >>> HTTP_COOKIE_ENCODE_NONE (same as setrawcookie) >>> HTTP_COOKIE_ENCODE_RFC1738 (same as setcookie) >>> HTTP_COOKIE_ENCODE_RFC3986 >>> >> > 2. I don't think this is necessary, nor that it belongs in the $options >> array. >> > > Most users dont know the correct encoding for cookies. This idea is from > the $enc_type parameter of http://php.net/http_build_query. The > documentation of http_cookie_set() should explain it the same way. > > Maybe i can move it out of the $options array and add an extra parameter > for the encoding, if the $options are the wrong location for this. > > > Anybody who'd use it, would have to read RFC1738 and/or RFC3986 to >> know what they do. >> > > This is the same as setcookie(). No one has to read the rfc, which is not > interested as it exactly works. HTTP_COOKIE_ENCODE_RFC1738 is the default > for the encode option and encode the value the same ways as setcookie > encode it. > > the default values for the options are the same as thr parameters for the > current setcookie(). The default values for the $options: > > expires: int, default: 0 > path: string, default: "" > domain: string, default: "" > secure: bool, default: false > httponly: bool, default: false > encode: int, default: HTTP_COOKIE_ENCODE_RFC1738 > > > And as the constant names aren't particularly short either, it is >> easier for me to just apply an encoding function directly to $value >> before passing it. >> > > The current names of the constants are not short, but in most cases i > think you dont need it. > > > Also, RFC 6265 (section 4.1.1) only mentions Base64 as a suggestion >> for encoding (and that's a SHOULD). >> Link: https://tools.ietf.org/html/rfc6265#section-4.1.1 >> > > http_cookie_set() use the same encoding per default as setcookie(). > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > As an average developer, I see providing new functions with http_ prefix more meaningful and their API more simple because of fewer parameters I need to pass. Although however, I see the naming convention you've used is rarely used. Looking in the docs, there are few other HTTP sapi related functions which don't follow that convention, like: header() - Send a raw HTTP header header_remove() - Remove previously set headers header_register_callback() - Call a header function headers_sent() - Checks if or where headers have been sent - this function uses referencing for retrieving the file name and line number :/ ughhhh... headers_list() - Returns a list of response headers sent (or ready to send) http_response_code() - Get or Set the HTTP response code - which is THE ONLY ONE function prefixed this way I just wanted to pay attention to a different naming convention which actually exists in language, which may need to be taken as a pursuit for all HTTP related functions. I like http_ prefixed functions because they point HTTP related nature and I think it may clear a little bit language API. P.S. headers_list() may be used to retrieve all headers which are sent (or ready to send) so you might consider introducing http_cookies_list() to retrieve all set (and not removed) cookies in current request lifecycle. Cheers, --=20 regards / pozdrawiam, -- Micha=C5=82 Brzuchalski about.me/brzuchal brzuchalski.com --94eb2c1b45026b20a805549abb32--