From 349f3e34dacac0b70866bb60de3d835b2c740674 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Mon, 27 Nov 2017 13:51:32 -0500 Subject: [PATCH 1/3] adding more details about sessions, including how to activate --- controller.rst | 54 ++++++++++++++++++++++++++++++++++++++++++++++---- session.rst | 9 +++++++++ 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/controller.rst b/controller.rst index 3418956d9ef..954ab9f26d0 100644 --- a/controller.rst +++ b/controller.rst @@ -417,10 +417,6 @@ front controller - see :ref:`page-creation-environments`). You'll want to customize the error page your user sees. To do that, see the :doc:`/controller/error_pages` article. -.. index:: - single: Controller; The session - single: Session - .. _controller-request-argument: The Request object as a Controller Argument @@ -443,6 +439,12 @@ object. To get it in your controller, just add it as an argument and :ref:`Keep reading ` for more information about using the Request object. +.. index:: + single: Controller; The session + single: Session + +.. _session-intro: + Managing the Session -------------------- @@ -450,6 +452,48 @@ Symfony provides a nice session object that you can use to store information about the user between requests. By default, Symfony stores the token in a cookie and writes the attributes to a file by using native PHP sessions. +First, enable sessions in your configuration: + +.. configuration-block:: + + .. code-block:: diff + + # config/packages/framework.yaml + framework: + # ... + + + session: + + # With this config, PHP's native session handling is used + + handler_id: ~ + + .. code-block:: xml + + + + + + + + + + + + .. code-block:: php + + // config/packages/framework.php + $container->loadFromExtension('framework', array( + 'session' => array( + // ... + 'handler_id' => null, + ), + )); + To retrieve the session, add the :class:`Symfony\\Component\\HttpFoundation\\Session\\SessionInterface` type-hint to your argument and Symfony will provide you with a session:: @@ -474,6 +518,8 @@ Stored attributes remain in the session for the remainder of that user's session Every ``SessionInterface`` implementation is supported. If you have your own implementation, type-hint this in the arguments instead. +For more info, see :doc:`/session`. + .. index:: single: Session; Flash messages diff --git a/session.rst b/session.rst index 33fbbc61745..3de4511dd22 100644 --- a/session.rst +++ b/session.rst @@ -1,6 +1,14 @@ Sessions ======== +Symfony provides a nice session object that you can use to store information +about the user between requests. + +To see how to use the session, read :ref:`session-intro`. + +More about Sessions +------------------- + .. toctree:: :maxdepth: 1 @@ -11,3 +19,4 @@ Sessions session/php_bridge session/proxy_examples +* :doc:`/doctrine/pdo_session_storage` From 29cd4996e1b9abc75fdaa7d5f080e5f743067398 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Wed, 29 Nov 2017 13:06:51 -0500 Subject: [PATCH 2/3] removing diff - does not work with config block --- controller.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/controller.rst b/controller.rst index 954ab9f26d0..479c570dd6e 100644 --- a/controller.rst +++ b/controller.rst @@ -456,15 +456,15 @@ First, enable sessions in your configuration: .. configuration-block:: - .. code-block:: diff + .. code-block:: yml # config/packages/framework.yaml framework: # ... - + session: - + # With this config, PHP's native session handling is used - + handler_id: ~ + session: + # With this config, PHP's native session handling is used + handler_id: ~ .. code-block:: xml From b95f550f5e95496c9743b6babbf5bd823b5c9ff3 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Wed, 29 Nov 2017 13:33:17 -0500 Subject: [PATCH 3/3] yaml --- controller.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controller.rst b/controller.rst index 479c570dd6e..b44b8273672 100644 --- a/controller.rst +++ b/controller.rst @@ -456,7 +456,7 @@ First, enable sessions in your configuration: .. configuration-block:: - .. code-block:: yml + .. code-block:: yaml # config/packages/framework.yaml framework: