pallets-eco / flask-session

Server side session extension for Flask
https://flask-session.readthedocs.io
BSD 3-Clause "New" or "Revised" License
501 stars 239 forks source link

Flask (sometimes) sends a `Set-Cookie` header for the session when serving .svg #108

Closed bakert closed 3 years ago

bakert commented 4 years ago

Is there some way to tell Flask that that is not appropriate and not to do it?

dltacube commented 4 years ago

You might be able to do something like flask.session.modified = False?

bakert commented 4 years ago

Thanks for the reply! As it stands most of these files are served "automatically" from the static_folder.

Our exact initialization looks like this:

class PDFlask(Flask):
    def __init__(self, import_name: str) -> None:
        shared_web_path = os.path.abspath(os.path.dirname(__file__))
        static_folder = os.path.join(shared_web_path, 'static')
        super().__init__(import_name, static_folder=static_folder)
        …

Is there a way to set flask.session.modified = False when setting from the static_folder?

bakert commented 4 years ago

I tried setting this for the favicon (where there is some explicit code rather than relying on url_for and static_folder) and it worked :)