A cookie is a tiny piece of information delivered by a web server to the browser. Every web server’s cookies are saved in a local file by the browser. The browser sends all saved cookies for that specific web server in a subsequent request.
The following are the distinctions between cookies and sessions:
-
A session works independent of the client browser’s settings. It’s possible that the client has chosen to disable cookies.
-
The quantity of data stored by sessions and cookies is also different. A cookie can only hold String objects, but an HTTP session may store any Java object.