The main difference between cookies and sessions is that cookies are stored in the user's browser, and sessions are not.
A cookie can keep information in the user's browser until deleted.
Sessions work instead like a token allowing access and passing information while the user has their browser open. The problem with sessions is that when you close your browser you also lose the session.
I have read the very good post on cookies and sessions with suitable php code.You can see that in http://cs-pages.blogspot.com/2011/05/difference-between-cookies-and-sessions.html | [reply] |
The problem with sessions is that when you close your browser you also lose the session.
That is not a property of sessions.
If closing your browser deletes cookies, and deletes the session cookie, then there is nothing associating your browser and the session, and the session can be considered lost.
If however, a session is also associated with an account, breaking the association with the browser (deleting cookies) doesn't break the association with the account -- you can resume the session after you log-in again
| [reply] |
Martin's answer is more self-serving than informative since the definitional difference between cookies and sessions are congruent among all languages. | [reply] |