Mysql session storage

I have read that storing the session in Mysql is beneficial when the site is running on multiple servers. I asked myself this question, what are the pros and cons of storing the session in the database. Maybe security is improved, as it becomes more difficult for an attacker to get to it?

Answer 1, authority 100%

There are situations when the session needs to be stored in the database, and there are situations when it is unnecessary, it all depends on the tasks being solved. However, when storing sessions in the database, you should think about the fact that the sessions will have to be cleared.

Getting to a session stored in the database is easier than when it is stored on the server.

Answer 2

If the site is so huge that it requires more than one server to run, most likely it may indeed need to store data in a database, on the other hand, if it is so huge, maybe you should consider choosing another DBMS? muscle is perfect for medium projects. For sites like VKontakte, mysql is not suitable, at least due to the size limit of mysql. Although I may be wrong.
I store authorization sessions in the database, but they are designed to control the presence / absence of a user on the site, by checking the session recording time, whether you need to do this depends on your needs (this is if the project is still not “VKontakte”).

Answer 3

Both there and there have their pros and cons, there is another way to store them in the memcache :). In fact, storing sessions in a database is interesting because you can kick all users from the server with one click of the mouse. That’s me, humor :).