header ad

Saturday, August 11, 2018

How would I find the user-agent from the http requests which were made to my website?

Questions:

  1. When users make requests to our website where is the information from our http request header stored?
  2. Can you access the user-agent from this (for example googlebot)[Would this be done with a serverside language like ruby/php?]
Answer

The user agent is an optional header for the http request your website receives. It's not necessarily 'stored' anywhere after the web request is complete. Depending on the logging on your web server, it may be part of the access log, or it may not be included in that log. If you haven't been logging or collecting the user agent headers, you don't have any way of getting them from requests that are already complete, but you can always start logging them now.

This header, like all the http headers, would be available to any server side script that was passed the request headers (I don't know of any server side that doesn't passed the headers one way or another), so the answer to your second question is, yes.

No comments:

Post a Comment