1. Introduction


After completing this module, you are expected to:

    • Use cookies as a means of establishing sessions.

          Have you heard of the term cookies while browsing the Internet? You may have encountered some browsers that make you accept cookies before you are able to enter the website. This allows the websites to keep track of your information so that it can customize the contents to improve your experience.

          Here’s a brief context to know more about where cookies are used. When you want to visit a webpage, your browser sends a request to the server in charge of that webpage. The server sends back the information that your browser requested, in the form of the webpage that you wanted to visit. Let’s say that you wanted the webpage to be displayed as dark mode on your browser so you set it to dark mode. You finish browsing and close the browser.

          When a server has sent a web page to your browser, the connection shuts down and the server forgets everything about you and your browser. The next time you visit the webpage, it has returned to its normal layout and you must click on the dark mode option again. You have to do this every time that you visit the webpage. This is the default function of the internet protocol and web services as being stateless. You can read more about this through this website: https://nordicapis.com/defining-stateful-vs-stateless-web-services/

          In order to avoid having to do things or give data over and over again every time you start anew, we need a way for the web page to “remember” who you are and what your preferences are. 

          Cookies are strings of information that are stored in browsers as text files. Your information related to a webpage is stored in cookies and these cookies are sent to servers along with your browser’s request. This way, the webpage “remembers” who you are and sets your preferences according to the cookies. Other examples of information that cookies store are usernames, display settings, and session key (information about the state of the connection).