In the field of Computer science, work is done on:
Server-side
Client-side
Server-side: When you go to a website, your computer talks to another computer (the "server") that has all the information for that website. The server-side code is what the server uses to give you the information you're asking for. It figures out what you want and sends it back to your computer, which shows you the website in your web browser. This server-side code may perform tasks such as accessing a database, running calculations, or generating dynamic content that is specific to the user or their interaction with the site.
Client-side: When you use a web application, like a website, there are two main parts: the part that runs on the server (the computer that hosts the website) and the part that runs on your own computer (in your web browser). The part that runs on your computer is called the "client side".
The client-side code is what your web browser uses to show you the website and let you interact with it. It includes things like the layout and design (which are defined using HTML and CSS), as well as any dynamic or interactive features (which are typically created using JavaScript).
When you interact with the website, like clicking a button or filling out a form, the client-side code sends a message to the server-side code (which runs on the website's host computer) to request information or perform an action. The server-side code then processes the request and sends a response back to the client-side code, which updates the website accordingly.
All three cookies, localStorage and sessionStorage are key-value storage mechanisms(sounds familiar?) on the client side.
COOKIES
Remember, when you visited that e-commerce site again, it had content similar to your last browsing products?
Cookies are small text files that are created and stored on your computer or device by a website when you visit it. They're used to store information about your visit, such as your preferences, login information, or shopping cart items.
When you visit a website, the website's server sends a cookie to your web browser, which stores it on your computer. The cookie is associated with the website's domain, so it can only be read by that website. The next time you visit the website, your browser sends the cookie back to the server, which can use the information stored in the cookie to remember your preferences or login status.
Cookies contain information that the website can use to remember things about you, like your login status, your language preference, or your shopping cart items. For example, if you log in to a website and select "remember me," the website will store a cookie on your computer that tells it you're logged in. That way, the next time you visit the site, you won't have to log in again.
They can only be read by the website only.
localStoage
localStorage is a way to store small amounts of data on a user's computer or device, similar to cookies. While cookies are typically used to store data that needs to be sent back to the server with each request, localStorage is used to store data that's only needed by the client-side code.
LocalStorage is a way for websites to store small amounts of data on your computer or device. This data can include things like your preferences, settings, or other information that can help make your experience on the website better.
Because the data is stored locally, it can be accessed quickly and doesn't require the website to talk to the server every time it needs to retrieve the data. This can make the website faster and more responsive.
sessionStorage
sessionStorage stores data only for the duration of the user's current browsing session. Once the user closes their web browser or navigates away from the website, the data stored in sessionStorage is lost.
It is commonly used for things like storing the state of a web application (such as which page or view the user is currently on), or temporary data that is used to enhance the user experience, like a search term or a filter option.
The data stored in sessionStorage is only available to the client-side code and can be used to store information that needs to be accessed across multiple pages or views within a website, but doesn't need to persist beyond the user's current session.
In general, server-side code is responsible for handling the back-end logic of an application, whereas client-side code (such as JavaScript running in a web browser) handles the front-end interactions and presentation of the application.
Have a look for conclusion:
Thanks for reading.