Skip to content

Documented the arguments of the Cookie class #6441

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 5 commits 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
48 changes: 47 additions & 1 deletion components/http_foundation/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,53 @@ 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 seven arguments in its constructor:

``$name``
**type**: ``string`` **default**: none (this argument is mandatory)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There always needs to be a blank line after the first line of the explanation (otherwise we would have only one paragraph for each explanation).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done that and I've improved the explanation of the $httpOnly argument.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also add a blank line before we describe the next term.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better. Done.


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 a timestamp integer,
a :phpfunction:`strtotime` valid date string (e.g. ``+1 week``), a
``DateTime`` object or 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
(which include both HTTP and HTTPS requests). If ``true``, the cookie won't
be accessible via non-HTTP methods, such as JavaScript's ``document.cookie``.

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