Skip to content

Documented the arguments of the Cookie class #6436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion components/http_foundation/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,45 @@ attribute::
The
:method:`Symfony\\Component\\HttpFoundation\\ResponseHeaderBag::setCookie`
method takes an instance of
:class:`Symfony\\Component\\HttpFoundation\\Cookie` as an argument.
:class:`Symfony\\Component\\HttpFoundation\\Cookie` as an argument. This class
takes eight arguments in its constructor:

``$name``
**type**: ``string`` **default**: none (this argument is mandatory)
The name of the cookie.
``$value``
**type**: ``string`` **default**: ``null``
The value stored in the cookie.
``$expire``
**type**: ``int``|``string``|``DateTime``|``DateTimeInterface`` **default**: 0
The time the cookie expires. This value can be set as a timestamp integer,
as a ``strtotime()`` valid date string (e.g. ``+1 week``), as a ``DateTime``
object or as an object which implements ``DateTimeInterface``.
The default value is ``0``, which deletes the cookie as soon as the browser
is closed.
``$path``
**type**: ``string`` **default**: ``/``
The path on the server in which the cookie will be available on. The default
values makes the cookie available on any URL of the server.
``$domain``
**type**: ``string`` **default**: ``null``
The domain that the cookie is available to. The default value makes the cookie
available just for the current domain (and any of its subdomains).
``$secure``
**type**: ``bool`` **default**: ``false``
Whether the cookie should only be transmitted over a secure HTTPS connection
from the client.
``$httpOnly``
**type**: ``bool`` **default**: ``true``
Whether the cookie will be made accessible only through the HTTP protocol.
``$raw``
.. versionadded:: 3.1
The ``$raw`` argument was introduced in Symfony 3.1.

**type**: ``bool`` **default**: ``false``
Whether the cookie value should be sent with no URL encoding. If set to
``true`` the cookie is created with the ``setrawcookie()`` PHP function
instead of ``setcookie()``.

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