Skip to content

Commit 86dfbfc

Browse files
committed
Documented the arguments of the Cookie class
1 parent d7724dd commit 86dfbfc

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

components/http_foundation/introduction.rst

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,45 @@ attribute::
377377
The
378378
:method:`Symfony\\Component\\HttpFoundation\\ResponseHeaderBag::setCookie`
379379
method takes an instance of
380-
:class:`Symfony\\Component\\HttpFoundation\\Cookie` as an argument.
380+
:class:`Symfony\\Component\\HttpFoundation\\Cookie` as an argument. This class
381+
takes eight arguments in its constructor:
382+
383+
``$name``
384+
**type**: ``string`` **default**: none (this argument is mandatory)
385+
The name of the cookie.
386+
``$value``
387+
**type**: ``string`` **default**: ``null``
388+
The value stored in the cookie.
389+
``$expire``
390+
**type**: ``int``|``string``|``DateTime``|``DateTimeInterface`` **default**: 0
391+
The time the cookie expires. This value can be set as a timestamp integer,
392+
as a ``strtotime()`` valid date string (e.g. ``+1 week``), as a ``DateTime``
393+
object or as an object which implements ``DateTimeInterface``.
394+
The default value is ``0``, which deletes the cookie as soon as the browser
395+
is closed.
396+
``$path``
397+
**type**: ``string`` **default**: ``/``
398+
The path on the server in which the cookie will be available on. The default
399+
values makes the cookie available on any URL of the server.
400+
``$domain``
401+
**type**: ``string`` **default**: ``null``
402+
The domain that the cookie is available to. The default value makes the cookie
403+
available just for the current domain (and any of its subdomains).
404+
``$secure``
405+
**type**: ``bool`` **default**: ``false``
406+
Whether the cookie should only be transmitted over a secure HTTPS connection
407+
from the client.
408+
``$httpOnly``
409+
**type**: ``bool`` **default**: ``true``
410+
Whether the cookie will be made accessible only through the HTTP protocol.
411+
``$raw``
412+
.. versionadded:: 3.1
413+
The ``$raw`` argument was introduced in Symfony 3.1.
414+
415+
**type**: ``bool`` **default**: ``false``
416+
Whether the cookie value should be sent with no URL encoding. If set to
417+
``true`` the cookie is created with the ``setrawcookie()`` PHP function
418+
instead of ``setcookie()``.
381419

382420
You can clear a cookie via the
383421
:method:`Symfony\\Component\\HttpFoundation\\ResponseHeaderBag::clearCookie` method.

0 commit comments

Comments
 (0)