Cookie and Session Pro/Cons

The benefits and drawbacks of each


A continuation/vaguely enlightened reflection on a previous post.

So. Cookies and sessions. Why would you use one or the other? Well, I did some researched and have compiled some reasons why.

Cookies

Pro:

Con:

Sessions

Pro

Con

So there are some of the reasons to use or not to use either sessions or cookies. If you want to store login data of some sort, like a cookie saying the person has been logged in, a cookie with an expiration date of some arbitrary long length of time would be best. But the sensitive data of the login would need to remain on the server, safe from manipulation. Sessions are seemingly more preferable, for the sake of being able to be used by the most amount of users, as Cookies can be blocked and deleted by users. But for the case of keeping a person logged in, cookies are still good and there are, as one can experience on various websites, ways of getting around that by having cookies and sessions doing the same thing.

Looking into the benefits/drawbacks of both methods of persisting data was very illuminating. It made me see them in a different light and from other perspectives, especially with the security and manipulating part, which I had forgotten to consider. I don’t think one is better than the other in any general-case—they each have their specific uses.