Hey guys,
Which one of the following methods is better in speed or security-wise to read/write data?
1) After successfully logging in, save necessary data in the session, and when those data are needed later on, retrieve them from session (for example, id, address, zipcode, etc.) Only update the data when necessary. Destroy them when the user logs out.
2) Retrieve/Update data from/to the database each time they are needed.
I have read several documents and articles about this, asked questions around, but I'm still not sure which one is better.
Some people say:
1 is not a good idea since PHP4 simply stores data in text-based session and reading/writing data from/to the text file takes longer. Also, when the access gets too crowded to one folder (in this case, session folder), that also slows down the speed. Session hijacking is also one of the issues.
2 is not a good idea because too many access to the database slows down the speed. Some of the hosting services limits the number of queries you can call within the certain amount of time, so if you have too many queries, this may end up being an annoying problem.
So which one is better then... Help me out!