Skip to content

Commit 331f095

Browse files
MathieuMatTheCat
Mathieu
authored andcommitted
[FrameworkBundle] update session configuration nodes’ documentation
1 parent a291585 commit 331f095

File tree

1 file changed

+60
-41
lines changed

1 file changed

+60
-41
lines changed

reference/configuration/framework.rst

Lines changed: 60 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,38 +1589,39 @@ You can also :ref:`store sessions in a database <session-database>`.
15891589
name
15901590
....
15911591

1592-
**type**: ``string`` **default**: ``null``
1592+
**type**: ``string``
1593+
1594+
This specifies the name of the session cookie.
15931595

1594-
This specifies the name of the session cookie. By default, it will use the
1595-
cookie name which is defined in the ``php.ini`` with the ``session.name``
1596-
directive.
1596+
If not set, ``php.ini``'s `session.name`_ directive will be relied on.
15971597

15981598
cookie_lifetime
15991599
...............
16001600

1601-
**type**: ``integer`` **default**: ``null``
1601+
**type**: ``integer``
16021602

1603-
This determines the lifetime of the session - in seconds. The default value
1604-
- ``null`` - means that the ``session.cookie_lifetime`` value from ``php.ini``
1605-
will be used. Setting this value to ``0`` means the cookie is valid for
1603+
This determines the lifetime of the session - in seconds.
1604+
Setting this value to ``0`` means the cookie is valid for
16061605
the length of the browser session.
16071606

1607+
If not set, ``php.ini``'s `session.cookie_lifetime`_ directive will be relied on.
1608+
16081609
cookie_path
16091610
...........
16101611

1611-
**type**: ``string`` **default**: ``/``
1612+
**type**: ``string``
1613+
1614+
This determines the path to set in the session cookie.
16121615

1613-
This determines the path to set in the session cookie. By default, it will
1614-
use ``/``.
1616+
If not set, ``php.ini``'s `session.cookie_path`_ directive will be relied on.
16151617

16161618
cache_limiter
16171619
.............
16181620

1619-
**type**: ``string`` or ``int`` **default**: ``''``
1621+
**type**: ``string`` **default**: ``'0'``
16201622

1621-
If set to ``0``, Symfony won't set any particular header related to the cache
1622-
and it will rely on the cache control method configured in the
1623-
`session.cache-limiter`_ PHP.ini option.
1623+
If set to ``'0'``, Symfony won't set any particular header related to the cache
1624+
and it will rely on ``php.ini``'s `session.cache_limiter`_ directive.
16241625

16251626
Unlike the other session options, ``cache_limiter`` is set as a regular
16261627
:ref:`container parameter <configuration-parameters>`:
@@ -1657,19 +1658,22 @@ Unlike the other session options, ``cache_limiter`` is set as a regular
16571658
'cache_limiter' => 0,
16581659
]);
16591660
1661+
Be aware that if you configure it, you'll have to set other session-related options
1662+
as parameters as well.
1663+
16601664
cookie_domain
16611665
.............
16621666

1663-
**type**: ``string`` **default**: ``''``
1667+
**type**: ``string``
1668+
1669+
This determines the domain to set in the session cookie.
16641670

1665-
This determines the domain to set in the session cookie. By default, it's
1666-
blank, meaning the host name of the server which generated the cookie according
1667-
to the cookie specification.
1671+
If not set, ``php.ini``'s `session.cookie_domain`_ directive will be relied on.
16681672

16691673
cookie_samesite
16701674
...............
16711675

1672-
**type**: ``string`` or ``null`` **default**: ``'lax'``
1676+
**type**: ``string`` or ``null`` **default**: ``null``
16731677

16741678
It controls the way cookies are sent when the HTTP request did not originate
16751679
from the same domain that is associated with the cookies. Setting this option is
@@ -1683,8 +1687,7 @@ those cookies when making that HTTP request.
16831687

16841688
The possible values for this option are:
16851689

1686-
* ``null``, use it to disable this protection. Same behavior as in older Symfony
1687-
versions.
1690+
* ``null``, use ``php.ini``'s `session.cookie_samesite`_ directive.
16881691
* ``'none'`` (or the ``Symfony\Component\HttpFoundation\Cookie::SAMESITE_NONE`` constant), use it to allow
16891692
sending of cookies when the HTTP request originated from a different domain
16901693
(previously this was the default behavior of null, but in newer browsers ``'lax'``
@@ -1698,18 +1701,20 @@ The possible values for this option are:
16981701

16991702
.. note::
17001703

1701-
This option is available starting from PHP 7.3, but Symfony has a polyfill
1702-
so you can use it with any older PHP version as well.
1704+
Same-site cookies are a PHP 7.3 feature, but Symfony has a polyfill
1705+
so you can set this option with any older PHP version as well.
17031706

17041707
cookie_secure
17051708
.............
17061709

1707-
**type**: ``boolean`` or ``'auto'`` **default**: ``'auto'``
1710+
**type**: ``boolean`` or ``'auto'``
17081711

17091712
This determines whether cookies should only be sent over secure connections. In
17101713
addition to ``true`` and ``false``, there's a special ``'auto'`` value that
17111714
means ``true`` for HTTPS requests and ``false`` for HTTP requests.
17121715

1716+
If not set, ``php.ini``'s `session.cookie_secure`_ directive will be relied on.
1717+
17131718
cookie_httponly
17141719
...............
17151720

@@ -1723,10 +1728,12 @@ identity theft through XSS attacks.
17231728
gc_divisor
17241729
..........
17251730

1726-
**type**: ``integer`` **default**: ``100``
1731+
**type**: ``integer``
17271732

17281733
See `gc_probability`_.
17291734

1735+
If not set, ``php.ini``'s `session.gc_divisor`_ directive will be relied on.
1736+
17301737
gc_probability
17311738
..............
17321739

@@ -1740,45 +1747,46 @@ chance that the GC process will start on each request.
17401747
gc_maxlifetime
17411748
..............
17421749

1743-
**type**: ``integer`` **default**: ``1440``
1750+
**type**: ``integer``
17441751

17451752
This determines the number of seconds after which data will be seen as "garbage"
17461753
and potentially cleaned up. Garbage collection may occur during session
17471754
start and depends on `gc_divisor`_ and `gc_probability`_.
17481755

1756+
If not set, ``php.ini``'s `session.gc_maxlifetime`_ directive will be relied on.
1757+
17491758
sid_length
17501759
..........
17511760

1752-
**type**: ``integer`` **default**: ``32``
1761+
**type**: ``integer``
17531762

17541763
This determines the length of session ID string, which can be an integer between
1755-
``22`` and ``256`` (both inclusive), being ``32`` the recommended value. Longer
1764+
``22`` and ``256`` (both inclusive), ``32`` being the recommended value. Longer
17561765
session IDs are harder to guess.
17571766

1758-
This option is related to the `session.sid_length PHP option`_.
1767+
If not set, ``php.ini``'s `session.sid_length`_ directive will be relied on.
17591768

17601769
sid_bits_per_character
17611770
......................
17621771

1763-
**type**: ``integer`` **default**: ``4``
1772+
**type**: ``integer``
17641773

17651774
This determines the number of bits in the encoded session ID character. The possible
17661775
values are ``4`` (0-9, a-f), ``5`` (0-9, a-v), and ``6`` (0-9, a-z, A-Z, "-", ",").
17671776
The more bits results in stronger session ID. ``5`` is recommended value for
17681777
most environments.
17691778

1770-
This option is related to the `session.sid_bits_per_character PHP option`_.
1779+
If not set, ``php.ini``'s `session.sid_bits_per_character`_ directive will be relied on.
17711780

17721781
save_path
17731782
.........
17741783

1775-
**type**: ``string`` **default**: ``%kernel.cache_dir%/sessions``
1784+
**type**: ``string`` or ``null`` **default**: ``%kernel.cache_dir%/sessions``
17761785

17771786
This determines the argument to be passed to the save handler. If you choose
17781787
the default file handler, this is the path where the session files are created.
17791788

1780-
You can also set this value to the ``save_path`` of your ``php.ini`` by
1781-
setting the value to ``null``:
1789+
If ``null``, ``php.ini``'s `session.save_path`_ directive will be relied on:
17821790

17831791
.. configuration-block::
17841792

@@ -1873,11 +1881,12 @@ Whether to enable the session support in the framework.
18731881
use_cookies
18741882
...........
18751883

1876-
**type**: ``boolean`` **default**: ``null``
1884+
**type**: ``boolean``
18771885

18781886
This specifies if the session ID is stored on the client side using cookies or
1879-
not. By default, it will use the value defined in the ``php.ini`` with the
1880-
``session.use_cookies`` directive.
1887+
not.
1888+
1889+
If not set, ``php.ini``'s `session.use_cookies`_ directive will be relied on.
18811890

18821891
assets
18831892
~~~~~~
@@ -3628,14 +3637,24 @@ use the configuration of the first exception that matches ``instanceof``:
36283637
.. _`json_encode flags bitmask`: https://www.php.net/json_encode
36293638
.. _`error_reporting PHP option`: https://www.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting
36303639
.. _`CSRF security attacks`: https://en.wikipedia.org/wiki/Cross-site_request_forgery
3631-
.. _`session.sid_length PHP option`: https://www.php.net/manual/session.configuration.php#ini.session.sid-length
3632-
.. _`session.sid_bits_per_character PHP option`: https://www.php.net/manual/session.configuration.php#ini.session.sid-bits-per-character
36333640
.. _`X-Robots-Tag HTTP header`: https://developers.google.com/search/reference/robots_meta_tag
36343641
.. _`RFC 3986`: https://www.ietf.org/rfc/rfc3986.txt
36353642
.. _`default_socket_timeout`: https://www.php.net/manual/en/filesystem.configuration.php#ini.default-socket-timeout
36363643
.. _`PEM formatted`: https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail
36373644
.. _`haveibeenpwned.com`: https://haveibeenpwned.com/
3638-
.. _`session.cache-limiter`: https://www.php.net/manual/en/session.configuration.php#ini.session.cache-limiter
3645+
.. _`session.name`: https://www.php.net/manual/en/session.configuration.php#ini.session.name
3646+
.. _`session.cookie_lifetime`: https://www.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime
3647+
.. _`session.cookie_path`: https://www.php.net/manual/en/session.configuration.php#ini.session.cookie-path
3648+
.. _`session.cache_limiter`: https://www.php.net/manual/en/session.configuration.php#ini.session.cache-limiter
3649+
.. _`session.cookie_domain`: https://www.php.net/manual/en/session.configuration.php#ini.session.cookie-domain
3650+
.. _`session.cookie_samesite`: https://www.php.net/manual/en/session.configuration.php#ini.session.cookie-samesite
3651+
.. _`session.cookie_secure`: https://www.php.net/manual/en/session.configuration.php#ini.session.cookie-secure
3652+
.. _`session.gc_divisor`: https://www.php.net/manual/en/session.configuration.php#ini.session.gc-divisor
3653+
.. _`session.gc_maxlifetime`: https://www.php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime
3654+
.. _`session.sid_length`: https://www.php.net/manual/en/session.configuration.php#ini.session.sid-length
3655+
.. _`session.sid_bits_per_character`: https://www.php.net/manual/en/session.configuration.php#ini.session.sid-bits-per-character
3656+
.. _`session.save_path`: https://www.php.net/manual/en/session.configuration.php#ini.session.save-path
3657+
.. _`session.use_cookies`: https://www.php.net/manual/en/session.configuration.php#ini.session.use-cookies
36393658
.. _`Microsoft NTLM authentication protocol`: https://docs.microsoft.com/en-us/windows/win32/secauthn/microsoft-ntlm
36403659
.. _`utf-8 modifier`: https://www.php.net/reference.pcre.pattern.modifiers
36413660
.. _`Link HTTP header`: https://tools.ietf.org/html/rfc5988

0 commit comments

Comments
 (0)