Using Sessions for Storing User Data
Let's see how to use sessions for storing user information.
We'll cover the following...
Sessions vs. cookies
Manipulation and visibility of cookie content
We saw how you can use cookies to pass data between requests. We ended with a warning that cookies can be manipulated, because they are headers, so they can’t really be trusted. Another security aspect is that the contents of cookies are visible. Both of these aspects of cookies make them unsuitable for sensitive information, or information that only you as the programmer should be able to manipulate.
...
Sessions come to rescue
For situations where using a cookie isn’t a good idea, but you still want to keep some kind of information between requests, you can use a session ...