Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: Limit to size of database-backed sessions?

Tags:

django

session

Django's documentation (here) state that cookie-based sessions can exceed the 'standard' of 4096 bytes per cookies.

What about database-backed sessions, is there a limit to the amount of data that can be stored in the session? I didn't see anything in the documentation, nor on SO.

For my project, I'll need to save ~50KB to a user's database-backed session. Let me know if you need more info.

like image 507
NickBraunagel Avatar asked Oct 27 '25 07:10

NickBraunagel


1 Answers

The database backend stores the session data in a TextField in the database.

The size limit of this field depends on your database backend, e.g., for Postgres (stored as text) it is unlimited, and for MySQL (stored as longtext) it is approximately 4GB.

Either way the limit is going to be far higher than ~50KB!

like image 80
solarissmoke Avatar answered Oct 28 '25 21:10

solarissmoke