How this happens, remain hidden. It is Hypertext Transport Protocol that makes it all possible. HTTP is a stateless protocol that defines how a Web browser communicates with a Web server. Once the user has started browsing a site, user sees related pages in a logical sequence. What actually happens is - every time the user clicks for a page, it goes to Web Server as a new HTTP request.
Every request is separate and distinct.
Web server cannot distinguish between the users or user requests for a web page. This means, all the web page requests of the user are distinct and do not depend upon the previous web page. Thousands of request come to the Web server every second. A cookie is a token of information stored on the user's machine. This piece of information comes from the web server, when the user makes an HTTP request.