Skip to content

Commit c0b8a48

Browse files
committed
feature symfony#13224 [HttpFoundation] Document the Cookie::with*() methods (javiereguiluz)
This PR was merged into the master branch. Discussion ---------- [HttpFoundation] Document the Cookie::with*() methods Fixes symfony#13016. Commits ------- d1dca39 [HttpFoundation] Document the Cookie::with*() methods
2 parents e0b177e + d1dca39 commit c0b8a48

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

components/http_foundation.rst

+15-3
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,21 @@ method takes an instance of
443443
You can clear a cookie via the
444444
:method:`Symfony\\Component\\HttpFoundation\\ResponseHeaderBag::clearCookie` method.
445445

446-
Note you can create a
447-
:class:`Symfony\\Component\\HttpFoundation\\Cookie` object from a raw header
448-
value using :method:`Symfony\\Component\\HttpFoundation\\Cookie::fromString`.
446+
In addition to the ``Cookie::create()`` method, you can create a ``Cookie``
447+
object from a raw header value using :method:`Symfony\\Component\\HttpFoundation\\Cookie::fromString`.
448+
You can also use the ``with*()`` methods to change some Cookie property (or to
449+
build the entire Cookie using a fluent interface). Each ``with*()`` method returns
450+
a new object with the modified property::
451+
452+
$cookie = Cookie::create('foo')
453+
->withValue('bar')
454+
->withExpiresTime(strtotime('Fri, 20-May-2011 15:25:52 GMT'))
455+
->withDomain('.example.com')
456+
->withSecure(true);
457+
458+
.. versionadded:: 5.1
459+
460+
The ``with*()`` methods were introduced in Symfony 5.1.
449461

450462
Managing the HTTP Cache
451463
~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)