Error in Flask while using flash(): TypeError

Viewed 777

I am new to Flask and am trying to use it with Google Cloud to build an app. When adding flash() statements to display error messages to users, I get the following error:

TypeError: set_cookie() got an unexpected keyword argument 'samesite'.

I am not sure how to fix this. I have set the secret_key and looked at the examples.

Any help with this is appreciated.

2 Answers

Your browser is sending a cookie with the SameSite cookie attribute, but your app doesn't support it.

Support for this attribute was added in Werkzeug 0.14 (the web application library that Flask uses). You need to upgrade your dependencies to use this newer version.

If you're using Google App Engine you can do this by adding this line in your requirements.txt file:

werkzeug>=0.14

just add this from flask import flash

Related