What is the difference between storing sessions in file and in database?
Difference between session in file and in database [closed]
Asked Answered
Why are people voting to close this? It's not a bad question if you don't know the answer. –
Flapper
Because no one could possibly guess what the OP is asking about. What sort of 'session'? What database? –
Whereabouts
I think guys closed this question to get SE indexed and also to feel important. Ego is a beast, that constantly needs feeding, right guys? This is a valid question. –
Unlike
The primary difference is that fetching the session info from a database can be quite a bit faster than from a file system. This is partly because of DB caching, but also because if there are large numbers of sessions files the file system may not cope well with it. Most file systems start to degrade when there are a few thousand files in a single directory, whereas DBs don't run into this problem.
Other reasons include fine-grained security, replication, and/or sharding, all of which are meat and potatoes to DBMSes, but not to filesystems.
If you only have a few sessions it doesn't matter, but when there 10,000 or 10,000,000 sessions it definitely does.
This answer is proof it is at least "a real question". It definitely can "be reasonably answered in its current form". –
Survey
Nope. This answer reflects using a ouija board to magically determine the actual subject matter of the question. –
Whereabouts
@bmargulies: Ouija board? Seriously? The OP wasn't asking about what a session is, or how to use a session, he was wondering why some sites use files to store session info and others use a DMBS. Given that the contents of a session don't vary based on its storage method, the only possible interpretation of his request that I could see was the relative benefits of one method over the other. –
Flapper
I can state about a dozen different uses of the term 'session' in the profession of computer-related engineering. You seem confident that you know which one the OP meant, but I, and others, are not. –
Whereabouts
After 40 years in the industry I'm sure that I could also make a list, but I choose to use the context of the matter at hand to limit the possibilities. I would be interested in seeing your list, given the context of this web site, of this question, and of this particular user, who seems to ask a fair number of PHP-related questions -- an environment where this type of decision needs to be made by the programmer. –
Flapper
@Peter Rowell Perfect answer Peter! –
Twiddle
© 2022 - 2024 — McMap. All rights reserved.