To share data that is valid for one request only from one function to another, a global variable is not good enough because it would break in threaded environments. Flask provides you with a special object that ensures it is only valid for the active request and that will return different values for each request. In a nutshell: it does the right thing, like it does for request and session.
The g object is a shared variable in a request, and different requests correspond to different g objects. In this case, you should use session. The session object is used to share variables between different requests. The most common one is to implement the login and logout function.
g is to share data between the program context and request context of a request. When you request the second time, g will not be the previous one. So you should use session or cookie
To share data that is valid for one request only from one function to another, a global variable is not good enough because it would break in threaded environments. Flask provides you with a special object that ensures it is only valid for the active request and that will return different values for each request. In a nutshell: it does the right thing, like it does for request and session.
你应该用session:http://flask.pocoo.org/docs/0.10/quickstart/#sessions
This is a question about flask session persistence.
You can refer to here first: http://docs.jinkan.org/docs/flask/quickstart.html#sessions
The g object is a shared variable in a request, and different requests correspond to different g objects. In this case, you should use session. The session object is used to share variables between different requests. The most common one is to implement the login and logout function.
g is to share data between the program context and request context of a request. When you request the second time, g will not be the previous one. So you should use session or cookie