Difference between Cookie and session

Difference between Cookie and session
CookieSession
Cookies are stored on client side browser.Session is stored on Server side
Storage limitation like IE 4096 bytes. We can create a maximum of 40 cookies.No limit on size or no. of sessions
Only string values can be stored in cookiesWe can store any objects in session
On the client machine, creating cookies should be enabled. People can block creation of cookies or they can clear cookies.Session is on server side so no need to worry about client machine
Cookies will be stored as long as we want, until user clears the browser history.But for session there is time out. When user closes the browser window, session ends
Cookies are non-secure since they are stored in text format. We should not store any sensitive data in cookiesSession is secure, because it is stored in encrypted binary format on server.
Cookies are used to store something that we want to know when the user returns to the webpage in future.(remember me check box)Session is used to remember something for that particular browser session
It is not user specific, It is machine specific. So if another person uses your machine and open the website with cookies created, they will be treated as if you have logged in.It is user specific.

0 comments:

Post a Comment