1.

What is the difference between a session and a cookie?

Answer»

The session and the cookies are both used to store user information for various purposes. They help the data to be passed between different parts of the website. There is a difference between a session and cookies.  

Sessions are saved on the server side i.e., in the case of an Express server, it will be stored on the stored server. But they are also temporary and get deleted the moment the user goes away. Suppose a user logs into a site, then their data will be stored in the session VARIABLES, for better programming purposes. The data stored in the server is also very much secure in comparison to the client and cannot be easily compromised. Each session of a user is UNIQUE so separate data is maintained for the same. 

On the other hand, a cookie is a text file of a maximum size of 4KB, which is stored on the client computer. It is ALWAYS stored as a string and is sent the first time the user visits the website. Cookies have many uses and they also used to keep track of users’ web-surfing behaviour, by tracking their browser history. Like when you VISIT a popular video streaming site and surf VIDEOS, the next time that site will show videos based on your earlier visit.



Discussion

No Comment Found