Answer the question
In order to leave comments, you need to log in
Where to store sessions? SQLite? MySQL? memcached? Redis? FS?
I store sessions in FS. For authorized users - in one folder, for unauthorized users - in another. In the folder unauthorized by the daemon, I go and delete the old sessions. It seems to be normal ... But I decided to look into the future: there are directories with unauthorized, especially with authorized sessions, packed to the brim! I saw a lot of disadvantages in this: reading the directory will become more difficult, I can exceed the limit on the number of files (I'm on shared hosting, since I have neither money nor brains for more).
In general, I decided that I needed to look for another repository. Read more about how to store...
Memcache
, зато нашёл Memcached
, его нужно было принудительно врубить… От куда взять сервер - я вообще без понятий)) Написал localhost с портом 11211… хз, вроде работает. С Redis'ом вообще ещё даже не ознокамливался. Ну это на потом. С кэшем я разберусь… Хотел бы в ОП хранить его, и буду. Но вот сессии… Answer the question
In order to leave comments, you need to log in
Store in muscle.
Files are really the worst option. Sarah Golemon, in a recent response to a similar question, wrote
File storage is only a default because the runtime doesn't know in advance what database engine or credentials you're going to use unless you tell it. So... ya know.... tell it.
SQLite and FS - absolutely not suitable if the application will scale
DB servers (MySQL / PostgreSQL / etc.) - reliable but slowest option
In-memory database (Redis / memcached) - excellent option, of all the above, the most productive, but you can to rest against the
Signed Cookie Session RAM (and its special case - JWT) - an option not described by you, the most economical in memory and disk and the most productive. The session is stored directly in the cookie. The data itself is serialized, for example, with JSON and compressed, for example, with gzip (but you can also take msgpack + lzma, whatever you like). After that, so that the user (or hacker) does not change the cookie at will, it is signed, for example, with HMAC + any crypto-resistant hash function
Of the pros
: 0 bytes of busy RAM (except for the moment the request is executed), 0 bytes of disk space occupied, no dependencies on databases sent on each request, there is a limit on the size of the data in the session, because the data must fit into the cookie, including the signature and delimiters. But for the sake of experiment, I managed to shove the first chapter of War and Peace condensed into such a session before hitting the limit.
(I'm on shared hosting because I don't have the money or brains for more).
You are right about whining. Same files, side view.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question