Difference b/w local storage and cookies:-
Cookies | Local storage | |
---|---|---|
Client side / Server side. | Data accessible both at client side and server side. Cookie data is sent to the server side with every request. | Data is accessible only at the local browser side. Server cannot access local storage until deliberately sent to the server via POST or GET. |
Size | 4095 bytes per cookie. | 5 MB per domain. |
Expiration | Cookies have expiration attached to it. So after that expiration the cookie and the cookie data get’s deleted. | There is no expiration data. Either the end user needs to delete it from the browser or programmatically using JavaScript we need to remove the same. |