tauren.kristich
tauren.kristich

Reputation: 479

Are Flask client side session stateless?

From what i've researched, Flask's sessions are by default on the client side. Wouldn't this mean that Flask by default is stateless?

Upvotes: 1

Views: 2774

Answers (1)

davidism
davidism

Reputation: 127230

No, Flask is not stateless, it has a built-in session implementation to hold state.

In addition to the request object there is also a second object called session which allows you to store information specific to a user from one request to the next.

Sessions by definition hold state. Wikipedia [1], [2]

HTTP sessions, which allow associating information with individual visitors

Cookies were designed to be a reliable mechanism for websites to remember stateful information

The HTTP request/response cycle, on it's own, is stateless. You use a session to persist state across requests. The form this session takes, whether it's a cookie stored client side, or a token to data stored server side, does not change the fact that a session is state.

Flask provides a way to override how sessions are handled. There are various extensions such as Flask-Login and Flask-Session which provide alternative ways to handle this, such as with a token and server-side session rather than the default cookie.

Upvotes: 4

Related Questions