Good day. I have a blog. I'm trying to improve adding comments by memorizing a name and email. addresses (i.e., the user will have to enter his name and address once, then it will be filled in automatically). How best to store it: in a cookie or in a session?
- session - on the server;
- Cookies are on the client.
Proceeding from security, user data must be stored in sessions (in this case the session hash identifier will be stored in cookies).
Cookies should also store data that is not confidential and requires long-term storage, for example, some statistics for marketing research, as well as indicators of various tools on the site for their visualization (as an example: hide this plate forever). Anyway, all the data that is not appropriate to store in the database.
For cookies and sessions, you can set the time of their life. However, sometimes the lifetime of sessions can be limited by hosting (free- / economy hosting)
Cookies are stored by the user and transmitted to the server each time (with each request). Session - is stored on the server and lives for a limited time, (usually 30 minutes) and the session id is also written in the cookie.
In your case, I think cookies will be better, and exactly what you need. Because lifetime - set by you or until deleted by the user, + the amount of information is not large to save traffic ...