No announcement yet.

Find out where you are?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Find out where you are?

    So maybe this is Javascript or PHP, but I must know.

    You know those sites that when you log on from where you are, they know where you are and take you to the site for that country? For instance, I took this American laptop to Japan, where I typed and it automatically sent me to and when I asked to keep me at, a cookie stayed ordering it to do that.

    I've noticed this with other sites as well, now that I'm in Mexico, some sites I visit go to their Mexican version.

    How is this done exactly? I would imagine it has to do with tracing the connection since I have only an American version of Windows installed.

  • #2
    There are 2 general ways this is done

    1) gets your ip, checks it and sees that you're from japan/mexico and then sends your to 'appropriate' place.
    2) google has a contract with a line of isp, iniated either by isp's or google itself. ISP's, knowing that you are their client, redirect your to cached version of googe in jp. Or it could be mirror, or even separate server just based in japan.

    However, there are downsides in each of the methods -
    1 is not reliable because, for example, australia shares it's ips with a number of other asian countries, and google can never be 100% sure they are doing the right thing. And
    2 is not all that great either becuase it requires quite close 'relationship' between isp and remote server.


    • #3
      Actually, your browser sends an Accept-Language header before it gets the page. On a PC, go to Tools -> Internet Options. Click Languages (at the bottom of the screen) You can set the language preferences there, and some sites use them. phpMyAdmin is an example of something that uses it.

      HTTP Requests are sent like this:
      GET / HTTP/1.1
      Accept-Language: en-us, de
      User-agent: Mozilla/4.0 (compatible; MSIE 5.14; Mac_PPC)
      There are more things sent by your browser, like Accept-Encoding, Cookie, and Connection, but that is something else.

      Last edited by MUG; Sun 5 Jan '03, 8:21am.


      • #4
        Why did I get Japanese though? The computer I had was American, with no trace of anything Japanese (I use another computer for my Japanese needs--and yet another for Spanish).

        Whenever I cleared cookies, I would get the same Japanese page again (while in Japan). Second I got back to America, it was gone.

        Oh well.


        • #5
          Did you even bother to read my reply?


          • #6
            Originally posted by AlCapone
            Did you even bother to read my reply?
            Three times, but it wasn't helpful, I asked how I could do it, not the process it takes which can be figured out using simple deductive logic.

            No offense


            • #7
              okie. It just from your post it didn't sound like you wanted to do it, and as it was more like 'how do they do it' kind of thread.

              If you want to do it, and you aren't big enough to have foreign isps make mirrors of you and/or keep server in foreign countries, then the only way you got is get user's ip, check against ip database and try to guess his nationality. Or, the easy way, is to ask visitors to select county themselves (that how many big boys do).

              'm not sure where you could get current ip table, but they used to be common couple of years ago.