-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
fixed example to check if the session exists when getting flash messages to avoid starting sessions when not needed #2564
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
Conversation
fabpot
commented
Apr 26, 2013
Q | A |
---|---|
Doc fix? | yes |
New docs? | no |
Applies to | all |
Fixed tickets | symfony/symfony#6036 |
As flash messages use a session to store the messages from one request to | ||
the next one, a session will be automatically started when you read the | ||
flash messages even if none already exists. To avoid that default | ||
behavior, test if there is an existing session first: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:
should be ::
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
…ges to avoid starting sessions when not needed
Hey guys! Before I merge this, I want to make sure I'm not missing something. Why would the following situation not cause a problem:
Is there some mechanism that would avoid this issue? More broadly, after reading symfony/symfony#6036, it sounds like we might need a small cookbook article on how to avoid starting the session (including the note about the flashbag and perhaps some notes about security). But we can handle that in another issue. Thanks! |
I don't understand how your scenario can happen. If you set something in the session in request 1, the session is going to be started in all sub-sequent requests. |
fixed example to check if the session exists when getting flash messages to avoid starting sessions when not needed
I've also opened #2607 as a reminder to add a bit more about this topic. Thanks! |
@fabpot is wrong about this. The session is not automatically started in later requests if it has been started before. |