Why is it good save to save sessions in the database?

后端 未结 6 1002
逝去的感伤
逝去的感伤 2020-12-04 11:05

I have seen that codeigniter have facility to save session values in database.
It says saving session in database is good security practice.

But I think saving

6条回答
  •  春和景丽
    2020-12-04 11:42

    A common security faux-pas with file-based sessions is to store them in /tmp or another shared directory where the data may be accessible to 3rd parties; especially on shared hosts this can be a problem. This can be prevented with proper file permissions though.

    Storing them in a database means you have all the access restrictions of the database in place, though that also means you need to configure them correctly and set up the physical storage of the database securely.

    It improves performance insofar as the database server has more layers to improve performance through caching and in-memory storage, whereas file based sessions always incur a disk access. Concurrent access can be improved since you can choose other concurrency mechanisms than file locking. If your database server is already busy with regular database work though, additionally throwing session handling at it may or may not be a good idea.

提交回复
热议问题