Skip to content
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

Fix session.py to allow suppression of the cookie #737

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bobintetley
Copy link

There are often endpoints/targets in your web.py app where you do not want to use sessions and most importantly, you do not want a Set-Cookie header sent with the response. The Set-Cookie header invalidates your Cache-Control directives when you are caching your responses with many CDNs. This PR allows you to do session.no_cookie=True in your handler to suppress the session cookie when you do not want it.

There are often endpoints/targets in your web.py app where you do not want to use sessions and most importantly, you do not want a Set-Cookie header sent with the response. The Set-Cookie header invalidates your Cache-Control directives when you are caching your responses with many CDNs. This PR allows you to do session.no_cookie=True in your handler to suppress the session cookie when you do not want it.
web/session.py Outdated Show resolved Hide resolved
@iredmail
Copy link
Contributor

iredmail commented Aug 7, 2022

Instead of using no_XXX = False, i prefer names like use_XXX = True. :)

@bobintetley
Copy link
Author

yep, it could certainly be send_cookie = True with the two booleans reversed. I mean, it's only a 2 line patch so whatever you prefer as maintainers!

@cclauss
Copy link
Contributor

cclauss commented Aug 7, 2022

Yes, please. Also please run the code thru psf/black so the tests pass.

@bobintetley
Copy link
Author

I'm sorry, I don't use psf/black and I have no idea why this is failing as the github error does not offer any indication why. I can't see anything wrong with the 3 lines of code in my patch with regards formatting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants