flask session related
Using flask, the default sessio is stored in the browser's cookie. When the request returns, the session will be written in the cookie, but when writing, the default is not rewritten every time.
For example the following example
#Original session {'k1': 1, 'k2': 'V2'} session[ ' user_info ' ][ ' k1 ' ]=2 #This way, the internal value session will not be rewritten
Modify becomes true only when the __setitem__ method or __deletitem__ method of the session object is called
#Method 1 session.modified = True #Method 2 Set the configuration parameter SESSION_REFRESH_EACH_REQUEST= True Recommended method 2 If there is a timeout, you need to refresh when you access. You
need to set session.parmanent=True when logging in
Session uses redis configuration
SESSION_KEY_PREFIX = ' hello ' # The key in redis will be prefixed with uuid money SESSION_TYPE = ' redis ' SESSION_REDIS = Redis(host= ' 127.0.0.1 ' ,port=6379 ) Also import from flask_session import Session Execute Session(app) after the app has loaded the configuration
---End of recovery content---