Tejesh Vemula
Tejesh Vemula

Reputation: 101

Where does Flask store the sessions?

I have recently started learning Python. I am currently trying to build a simple Web Application that requires a login to access some paths.

I understand that this can be achieved by using something like session['user']=user_id in Flask.

Can somebody help me with how exactly this works? Like where does Flask store the sessions if not in the database table?

Upvotes: 10

Views: 7478

Answers (1)

zwer
zwer

Reputation: 25809

It stores it in a cookie on the client side. From the official documentation:

This is implemented on top of cookies for you and signs the cookies cryptographically. What this means is that the user could look at the contents of your cookie but not modify it, unless they know the secret key used for signing.

If you need server-side session store, there is an extension called Flask-Sessionstore that lets you choose the method of storage, including server-side DBs.

Upvotes: 12

Related Questions