COOKIE
A cookie is a text-only string that takes a place in the memory of user’s browser.
If the lifetime of the cookie is set to be longer than the time user spends at that site, then this string is saved to file for future reference. User could be disabled the cookie in their browser setting.
SESSION
Session values are store in server side not in user’s machine.
A session is available as long as the browser is opened. User couldn’t be disabled the session. We could store not only strings but also objects in session.
The Differences
1. The key difference would be cookies are stored in client side and sessions are stored in server side.
2. The second difference would be cookies can only store strings. We can store our objects in sessions. Storing objects in sessions were really useful according to my experience.
3. Another difference was that we could be save cookie for future reference, but session couldn’t.
When users close their browser, they also lost the session.
A cookie is a text-only string that takes a place in the memory of user’s browser.
If the lifetime of the cookie is set to be longer than the time user spends at that site, then this string is saved to file for future reference. User could be disabled the cookie in their browser setting.
SESSION
Session values are store in server side not in user’s machine.
A session is available as long as the browser is opened. User couldn’t be disabled the session. We could store not only strings but also objects in session.
The Differences
1. The key difference would be cookies are stored in client side and sessions are stored in server side.
2. The second difference would be cookies can only store strings. We can store our objects in sessions. Storing objects in sessions were really useful according to my experience.
3. Another difference was that we could be save cookie for future reference, but session couldn’t.
When users close their browser, they also lost the session.
No comments:
Post a Comment