File tree Expand file tree Collapse file tree 7 files changed +41
-1
lines changed
Security/Tests/Http/Firewall Expand file tree Collapse file tree 7 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -518,7 +518,7 @@ public function hasPreviousSession()
518518 */
519519 public function hasSession ()
520520 {
521- return null !== $ this ->session ;
521+ return null !== $ this ->session && $ this -> session -> isStarted () ;
522522 }
523523
524524 /**
Original file line number Diff line number Diff line change @@ -130,6 +130,14 @@ public function clear()
130130 $ this ->storage ->getBag ($ this ->attributeName )->clear ();
131131 }
132132
133+ /**
134+ * {@inheritdoc}
135+ */
136+ public function isStarted ()
137+ {
138+ return $ this ->storage ->isStarted ();
139+ }
140+
133141 /**
134142 * Returns an iterator for attributes.
135143 *
Original file line number Diff line number Diff line change @@ -174,6 +174,15 @@ function remove($name);
174174 */
175175 function clear ();
176176
177+ /**
178+ * Check if a session was started
179+ *
180+ * @api
181+ *
182+ * @return boolean
183+ */
184+ public function isStarted ();
185+
177186 /**
178187 * Registers a SessionBagInterface with the session.
179188 *
Original file line number Diff line number Diff line change @@ -199,6 +199,16 @@ public function getBag($name)
199199 return $ this ->bags [$ name ];
200200 }
201201
202+ /**
203+ * Check if the session was started or not
204+ *
205+ * @return boolean
206+ */
207+ public function isStarted ()
208+ {
209+ return $ this ->started ;
210+ }
211+
202212 /**
203213 * Sets the MetadataBag.
204214 *
Original file line number Diff line number Diff line change @@ -289,6 +289,16 @@ public function getMetadataBag()
289289 return $ this ->metadataBag ;
290290 }
291291
292+ /**
293+ * Check if the session was started or not
294+ *
295+ * @return boolean
296+ */
297+ public function isStarted ()
298+ {
299+ return $ this ->started ;
300+ }
301+
292302 /**
293303 * Sets session.* ini variables.
294304 *
Original file line number Diff line number Diff line change @@ -884,6 +884,7 @@ public function testHasSession()
884884
885885 $ this ->assertFalse ($ request ->hasSession ());
886886 $ request ->setSession (new Session (new MockArraySessionStorage ()));
887+ $ request ->getSession ()->start ();
887888 $ this ->assertTrue ($ request ->hasSession ());
888889 }
889890
@@ -895,6 +896,7 @@ public function testHasPreviousSession()
895896 $ request ->cookies ->set ('MOCKSESSID ' , 'foo ' );
896897 $ this ->assertFalse ($ request ->hasPreviousSession ());
897898 $ request ->setSession (new Session (new MockArraySessionStorage ()));
899+ $ request ->getSession ()->start ();
898900 $ this ->assertTrue ($ request ->hasPreviousSession ());
899901 }
900902
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ public function testOnKernelResponseWillRemoveSession()
8585 protected function runSessionOnKernelResponse ($ newToken , $ original = null )
8686 {
8787 $ session = new Session (new MockArraySessionStorage ());
88+ $ session ->start ();
8889
8990 if ($ original !== null ) {
9091 $ session ->set ('_security_session ' , $ original );
You can’t perform that action at this time.
0 commit comments