Search code examples
browsertabs

How does a server know which browser or tab I am using?


I had this question for an interview. Can you tell me how a server know which tab or browser I am using for a specific website?


Solution

  • There is a header called User-Agent that is sent to the server when a user makes a request from the browser. It looks like this:

    User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/12.0
    

    It clearly tells you that the browser is mozilla, although there is some extra information for historical reasons that you souldn't worry about.

    A header is a type of meta information that the users doesn't see but helps the server communicate with the client by sharing this kind of information. So you are able to serve different pages to different pages if the client is using an outdated browser.

    You can't know what tab the client is using.