Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
125
rated 0 times [  129] [ 4]  / answers: 1 / hits: 20396  / 9 Years ago, tue, september 8, 2015, 12:00:00

There are many SO questions how to get http headers with javascript, but for some reason they don't show up HTTP_CF_IPCOUNTRY header.



If I try to do with php echo $_SERVER[HTTP_CF_IPCOUNTRY];, it works, so CF is working just fine.



Is it possible to get this header with javascript?


More From » cloudflare

 Answers
4

Assuming you are talking about client side JavaScript: no, it isn't possible.




  1. The browser makes an HTTP request to the server.

  2. The server notices what IP address the request came from

  3. The server looks up that IP address in a database and finds the matching country

  4. The server passes that country to PHP



The data never even goes near the browser.



For JavaScript to access it, you would need to read it with server side code and then put it in a response back to the browser.


[#65147] Saturday, September 5, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dequant

Total Points: 88
Total Questions: 99
Total Answers: 95

Location: Ukraine
Member since Sun, Dec 13, 2020
4 Years ago
dequant questions
;