From 490efdcc4c172ac18e19129e19cf213abff626f2 Mon Sep 17 00:00:00 2001 From: scottwarren Date: Mon, 7 Apr 2014 19:46:51 +1000 Subject: [PATCH 1/9] Updated references to new Session() If you use new Session(), you get a 500 error, with the following message: ```log Failed to start the session: already started by PHP. ``` --- components/http_foundation/sessions.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/http_foundation/sessions.rst b/components/http_foundation/sessions.rst index dd5ddfdba54..86e58c9d829 100644 --- a/components/http_foundation/sessions.rst +++ b/components/http_foundation/sessions.rst @@ -16,7 +16,7 @@ Quick example:: use Symfony\Component\HttpFoundation\Session\Session; - $session = new Session(); + $session = $this->getRequest()->getSession(); $session->start(); // set and get session attributes @@ -291,7 +291,7 @@ Examples of setting multiple flashes:: use Symfony\Component\HttpFoundation\Session\Session; - $session = new Session(); + $session = $this->getRequest()->getSession(); $session->start(); // add flash messages From a64f27466c367bfea271ca64f7ffc44f5c522661 Mon Sep 17 00:00:00 2001 From: scottwarren Date: Mon, 7 Apr 2014 19:53:51 +1000 Subject: [PATCH 2/9] Removed use command As it is no longer needed --- components/http_foundation/sessions.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/http_foundation/sessions.rst b/components/http_foundation/sessions.rst index 86e58c9d829..a1cda0092cb 100644 --- a/components/http_foundation/sessions.rst +++ b/components/http_foundation/sessions.rst @@ -14,8 +14,6 @@ implementation of :class:`Symfony\\Component\\HttpFoundation\\Session\\SessionIn Quick example:: - use Symfony\Component\HttpFoundation\Session\Session; - $session = $this->getRequest()->getSession(); $session->start(); @@ -289,8 +287,6 @@ to be used for more complex messaging in your application. Examples of setting multiple flashes:: - use Symfony\Component\HttpFoundation\Session\Session; - $session = $this->getRequest()->getSession(); $session->start(); From 275dd97b76f46fe0ab33df134ba9240d0bb12fc1 Mon Sep 17 00:00:00 2001 From: scottwarren Date: Mon, 7 Apr 2014 20:18:26 +1000 Subject: [PATCH 3/9] Added Caution note --- components/http_foundation/sessions.rst | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/components/http_foundation/sessions.rst b/components/http_foundation/sessions.rst index a1cda0092cb..dbf219c8ce1 100644 --- a/components/http_foundation/sessions.rst +++ b/components/http_foundation/sessions.rst @@ -12,9 +12,16 @@ object-oriented interface using a variety of session storage drivers. Sessions are used via the simple :class:`Symfony\\Component\\HttpFoundation\\Session\\Session` implementation of :class:`Symfony\\Component\\HttpFoundation\\Session\\SessionInterface` interface. +.. caution:: + + Make sure your Sessions aren't already initliazed (which in Symfony is done automatically), + as initializing the Session object causes the session to be started, which can lead to unexpected errors. + Quick example:: - $session = $this->getRequest()->getSession(); + use Symfony\Component\HttpFoundation\Session\Session; + + $session = new Session(); $session->start(); // set and get session attributes @@ -287,7 +294,9 @@ to be used for more complex messaging in your application. Examples of setting multiple flashes:: - $session = $this->getRequest()->getSession(); + use Symfony\Component\HttpFoundation\Session\Session; + + $session = new Session(); $session->start(); // add flash messages From df4ef144dc73cab287eae4f52ef551497ac88278 Mon Sep 17 00:00:00 2001 From: scottwarren Date: Mon, 7 Apr 2014 20:30:31 +1000 Subject: [PATCH 4/9] Added extra new lines Added new lines after 72 characters to conform with character limit standards --- components/http_foundation/sessions.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/http_foundation/sessions.rst b/components/http_foundation/sessions.rst index dbf219c8ce1..bde670f9a07 100644 --- a/components/http_foundation/sessions.rst +++ b/components/http_foundation/sessions.rst @@ -14,8 +14,9 @@ implementation of :class:`Symfony\\Component\\HttpFoundation\\Session\\SessionIn .. caution:: - Make sure your Sessions aren't already initliazed (which in Symfony is done automatically), - as initializing the Session object causes the session to be started, which can lead to unexpected errors. + Make sure your Sessions aren't already initliazed (which in Symfony is + done automatically), as initializing the Session object causes the + session to be started, which can lead to unexpected errors. Quick example:: From 6e6b19f2f5ef75ab52832292b131d646646b7adc Mon Sep 17 00:00:00 2001 From: scottwarren Date: Mon, 7 Apr 2014 20:35:31 +1000 Subject: [PATCH 5/9] Fixed typo and removed extra space --- components/http_foundation/sessions.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/http_foundation/sessions.rst b/components/http_foundation/sessions.rst index bde670f9a07..77a1e166366 100644 --- a/components/http_foundation/sessions.rst +++ b/components/http_foundation/sessions.rst @@ -14,9 +14,10 @@ implementation of :class:`Symfony\\Component\\HttpFoundation\\Session\\SessionIn .. caution:: - Make sure your Sessions aren't already initliazed (which in Symfony is - done automatically), as initializing the Session object causes the - session to be started, which can lead to unexpected errors. + Make sure your Sessions aren't already initliazed (which is done + automatically in the full-stack framework), as initializing the + Session object causes the session to be started, which can lead + to unexpected errors. Quick example:: From b2ac5bc0ce7d6ee9c1998df5e004ead982f9b6a7 Mon Sep 17 00:00:00 2001 From: scottwarren Date: Mon, 7 Apr 2014 20:38:37 +1000 Subject: [PATCH 6/9] fixed typo --- components/http_foundation/sessions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/http_foundation/sessions.rst b/components/http_foundation/sessions.rst index 77a1e166366..dc37a721dc2 100644 --- a/components/http_foundation/sessions.rst +++ b/components/http_foundation/sessions.rst @@ -14,7 +14,7 @@ implementation of :class:`Symfony\\Component\\HttpFoundation\\Session\\SessionIn .. caution:: - Make sure your Sessions aren't already initliazed (which is done + Make sure your Sessions aren't already initialized (which is done automatically in the full-stack framework), as initializing the Session object causes the session to be started, which can lead to unexpected errors. From 3624fecd6d6b7ba7f657ededf31f8bd6957d7484 Mon Sep 17 00:00:00 2001 From: scottwarren Date: Mon, 7 Apr 2014 21:01:28 +1000 Subject: [PATCH 7/9] Updated grammer issues in caution section --- components/http_foundation/sessions.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/http_foundation/sessions.rst b/components/http_foundation/sessions.rst index dc37a721dc2..50ab7ac3af5 100644 --- a/components/http_foundation/sessions.rst +++ b/components/http_foundation/sessions.rst @@ -14,10 +14,10 @@ implementation of :class:`Symfony\\Component\\HttpFoundation\\Session\\SessionIn .. caution:: - Make sure your Sessions aren't already initialized (which is done - automatically in the full-stack framework), as initializing the - Session object causes the session to be started, which can lead - to unexpected errors. + Make sure your sessions aren't already initialized (which is, + for example, automatically done in the full-stack framework). + As initializing the Session object causes the session to be + started, which can lead to unexpected errors. Quick example:: From 4e06f0ebb5959ae22b8004dbce351cac3f389bf3 Mon Sep 17 00:00:00 2001 From: scottwarren Date: Mon, 7 Apr 2014 21:27:20 +1000 Subject: [PATCH 8/9] fixed spaces and 72 char line limit --- components/http_foundation/sessions.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/http_foundation/sessions.rst b/components/http_foundation/sessions.rst index 50ab7ac3af5..abda71ba794 100644 --- a/components/http_foundation/sessions.rst +++ b/components/http_foundation/sessions.rst @@ -14,10 +14,10 @@ implementation of :class:`Symfony\\Component\\HttpFoundation\\Session\\SessionIn .. caution:: - Make sure your sessions aren't already initialized (which is, - for example, automatically done in the full-stack framework). - As initializing the Session object causes the session to be - started, which can lead to unexpected errors. + Make sure your sessions aren't already initialized (which is, for example, + automatically done in the full-stack framework). As initializing the + Session object causes the session to be started, which can lead to unexpected + errors. Quick example:: From fa86275d8da59207ceb178dea371dd90d1c5438c Mon Sep 17 00:00:00 2001 From: Scott Warren Date: Wed, 7 May 2014 07:05:03 +1000 Subject: [PATCH 9/9] Updated warning for Sessions --- components/http_foundation/sessions.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/http_foundation/sessions.rst b/components/http_foundation/sessions.rst index abda71ba794..07e1331ffde 100644 --- a/components/http_foundation/sessions.rst +++ b/components/http_foundation/sessions.rst @@ -14,10 +14,9 @@ implementation of :class:`Symfony\\Component\\HttpFoundation\\Session\\SessionIn .. caution:: - Make sure your sessions aren't already initialized (which is, for example, - automatically done in the full-stack framework). As initializing the - Session object causes the session to be started, which can lead to unexpected - errors. + Make sure your PHP session isn't already started before using the Session + class. If you have a legacy session system that starts your session, see + http://symfony.com/doc/current/components/http_foundation/session_php_bridge.html Quick example::