Request.ServerVariables in classic Asp

442 views Asked by At

I have this requirement: I need to save the search word made by a user who has come to my site. The site is made in classic asp. I have tried with: Request.ServerVariables ("HTTP_REFERER") Request.ServerVariables ("ALL_HTTP")

But I don't get the search query (q=) https://www.google.com/search?q=house

How can I get the value of q= ?

1

There are 1 answers

5
TiK On

The following code will give you what you are looking for:

    Response.Write(Split(Split(Request.ServerVariables ("HTTP_REFERER"), "?")(1),"=")(1))

For sure, you will need to adapt it : if you don't have query string, it will fail, and the parameter you are looking for needs to be the first one.