Description
UPDATE: This issue has 2 parts. The first one is explained in this post. The second one is explained in this comment.
I noticed the website I am developing was sending a cookie in the response, even for anonymous requests (ie: not logged in, and deleted all cookies).
After trying everything and failing to find the problem, I created a "hello world" with a fresh install, and there was no cookie.
But as soon as I added this, the cookie came back:
{% for flashMessage in app.session.flashbag.get('success') %}
<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">×</button>
{{ flashMessage }}
</div>
{% endfor %}
So apparently app.session.flashbag.get()
creates the session. I'm sure many other parts of my website are unintentionally creating a session, and that's why I couldn't find the culprit.
Is there a reason for this? Isn't it adding overhead that could have been avoided? I imagine this won't affect sites that are login-only, as they will need the session anyway for most of the visits. But sites that can be used anonymously might suffer a bit.