Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78558 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46193 invoked from network); 2 Nov 2014 10:24:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Nov 2014 10:24:29 -0000 Authentication-Results: pb1.pair.com smtp.mail=mike.php.net@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=mike.php.net@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.47 as permitted sender) X-PHP-List-Original-Sender: mike.php.net@gmail.com X-Host-Fingerprint: 74.125.82.47 mail-wg0-f47.google.com Received: from [74.125.82.47] ([74.125.82.47:54338] helo=mail-wg0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A0/23-13276-A5606545 for ; Sun, 02 Nov 2014 05:24:27 -0500 Received: by mail-wg0-f47.google.com with SMTP id a1so9209692wgh.20 for ; Sun, 02 Nov 2014 02:24:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=kfveejx4jEBJrZce6muQNLNgvppYA2O+huktpvwu2uU=; b=bO30xXU3KNiVYrpprMzXJQjl2CE1fGPxvJOe3tBOzP7kPp8JCpwK+splE/0B0RxNyR ZVsa4AhtXIKHgxPa128NH9MIGLjfSvK70Eg9Nkzvfr3YgS2qDM4NXUWXRy3AHRRwB5LH F9Z2Y6cX6kbQM4UIVHpb8p7NClPlVfr9dFnAOFRbu0IUwmwSDxLmbutppv9HZ8mWtfLx LQU/3JsGCXMDu946Y4gfOzAajSifZLjdAX20w6J7l8oUiE0iry8009v8jOEmnZplUGlW cP6kWbyvst+NSJHoOXCbbDANoBIX7A7sH2oc/5JZXlstv0kaoCr2cM8ceCApqYkzIyWJ PAoQ== X-Received: by 10.194.3.2 with SMTP id 2mr2361434wjy.89.1414923862948; Sun, 02 Nov 2014 02:24:22 -0800 (PST) Received: from [192.168.1.170] (95-143-224-254.customer.bnet.at. [95.143.224.254]) by mx.google.com with ESMTPSA id bl9sm4685219wib.24.2014.11.02.02.24.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Nov 2014 02:24:21 -0800 (PST) Sender: Michael Wallner Content-Type: multipart/alternative; boundary="Apple-Mail=_E1A31F89-E4F8-47A1-B808-1B78BE8E3A01" Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) In-Reply-To: <54557BCE.1070405@gmail.com> Date: Sun, 2 Nov 2014 11:24:20 +0100 Cc: internals@lists.php.net Message-ID: <4E0A311A-EF18-4EC3-AD9D-520B2B705EAD@php.net> References: <545554F7.70906@gmail.com> <581CB00C-59B7-4263-8533-D7DCB54C806E@ajf.me> <54557BCE.1070405@gmail.com> To: Rowan Collins X-Mailer: Apple Mail (2.1990.1) Subject: Re: [PHP-DEV] setcookie() minor BC break - fixes issue #67736 From: mike@php.net (Michael Wallner) --Apple-Mail=_E1A31F89-E4F8-47A1-B808-1B78BE8E3A01 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 02 11 2014, at 01:33, Rowan Collins = wrote: >=20 > On 01/11/2014 22:24, Andrea Faulds wrote: >> Perhaps it would be worth ditching any attempts to change setcookie() = (just keep it around for backwards-compatibility), and to instead add a = new function, function family, or indeed class for cookie handling. Some = sort of sane API which would allow you to do a, b, or c, and make it = clear which you wanted. >>=20 >> Thoughts? Any idea what such an API might look like? >=20 > That rather brings us back to this week's Hot Topic: HTTP response = objects, pecl/http, and PSR-7. >=20 > pecl/httpv2 has the http\Cookie class [1], which confusingly = represents not a single cookie, but a whole set of cookies. Exactly how = you attach this to a response is not really clear from the docs I can = find. >=20 It it=E2=80=99s confusing, the docs are not good enough, and I probably = have to agree here ;) Anyway, http\Cookie can parse Cookie and Set-Cookie headers, though, = looking at the RFC that might have been a bad idea to implement it that = way. Cookies never have been a main area of interest to me, so there might be = a lot of room to improve in pecl/http. Obviously, API for cookies is completely missing in the http\Env sub = namespace, probably because there was $_COOKIE and set_cookie(), which = may have covered my needs for it. Setting a cookie currently would mean = just setting the appropriate Set-Cookie header on an http\Env\Response = instance. - - - 8< - - - $ php -r '$r =3D new http\Env\Response; \ $r->setHeader("Set-Cookie", \ ((new http\Cookie("foo=3Dbar"))->setExpires(strtotime("+1 day")))); = \ $r->send(STDOUT);=E2=80=99 =20 HTTP/1.1 200 OK Set-Cookie: foo=3Dbar; expires=3DMon, 03 Nov 2014 10:21:43 GMT;=20 ETag: "" - - - >8 - - - > [1] http://devel-m6w6.rhcloud.com/mdref/http/Cookie = Cheers, Mike --Apple-Mail=_E1A31F89-E4F8-47A1-B808-1B78BE8E3A01--