Forums

Error : Flask Global variables shared among users

Hello ! We are building a simple chatbot that can collect data from user like name and some other details. The problem we have now is when more than one user attempts to use the chatbot, the global variables get collapsed (it gets shared among the users) . We saw posts that say " you should use 'SESSION' on flask to achieve this" but we are confused how to set up and use . The objective of our python code is to get data from each user and it should not be shared how can we achieve this using SESSION ? Help us . Thanks in advance.

The Flask session documentation is here: https://flask.palletsprojects.com/en/1.1.x/api/?highlight=session#sessions. Essentially, the session object is a dictionary and you can just set key in it. Be aware that the default Flask session implementation stores the session data in a cookie, so they data you store there cannot be too large. That is not greater than about 4k.