Cookies are small piece of data generated as a response to the request made by the client to the server. These are used to store multiple types of information based on its type.
sessionStorage is basically a record of unique data created for a particular user so that server can make sure that the user is currently authenticated for secure access of areas which are not accessible to unauthenticated users thus providing protection of user as well as server.
localStorage is a space provided within a browser where web applications can store data that can be used while application is being executed or for later use. Unlike cookies, a large amount of data can be stored in local storage without compromising with the performance of website