1

I am trying to find out the location of a user when he is visiting my website.

I have tried out to locate user's ip using php from this question and I understand the security importance of $_SERVER['HTTP_X_FORWARDED_FOR'] (article). With the users ip I am using Maxmind geolocation service to locate my user (lat/lon and city if possible).

Can anyone suggest me another way to locate users position, except the one with javascript that user accepts to locate his position in browser?

In case of using a geolocation service can you suggest any other with high accuracy? I have read this publication but its pretty old.

Community
  • 1
  • 1
jsurf
  • 189
  • 3
  • 11
  • You can't, it's impossible. GeoIP services will always have inaccuracies, and the user does not have to accept if you use HTML5 location to ask for their location. – Luna Jun 01 '16 at 12:31
  • @RossAllan I am going to check navigator.geolocation. Regarding the accuracy can you suggest any other service ? Is there any other solution regarding locating user's position? – jsurf Jun 01 '16 at 12:52
  • When I executed for the first time the navigator.geolocation function the browser ask for permission to locate my position. I don't want this to happen because it has a negative impact on the experience. – jsurf Jun 01 '16 at 13:02
  • By design, browsers ask for permission to keep the user's privacy. If they don't want you to know the location, you'll have to stick with inaccurate GeoIP. If you're trying to auto-fill information to save the user time, eg, filling in an address, use GeoIP to determine the country, and use the location info if they accept. Otherwise they'll have to fill it in themselves and that's fine. Do you absolutely need to accurately know the user's location, or is it just something you'd like to have? I don't think what you want is possible. – Luna Jun 01 '16 at 13:32
  • @RossAllan yes finding out the users location (lat/lon or city) is upgrading the service. The info that I am presenting when a user visits the website is personalised based on his location (on a city level). At the moment I am getting his IP based on the "question" link I posted above and together with a geolocation service like GeoIP I am having pretty good results. But I was wondering if I can follow any other way to find out his location. – jsurf Jun 01 '16 at 13:48

1 Answers1

0

You can use GeoIP location services, who have various levels of accuracy. There may be other providers of IP-location databases too.

Another option is to try to use HTML5 location services, such as in http://html5demos.com/geo and http://dev.w3.org/geo/api/spec-source.html.

Jayesh Chitroda
  • 4,987
  • 13
  • 18
  • Do you mean GeoIP by Maxmind? If yes I am using it already. I am asking if you know/used before another IP-location database. It will be great if its going to be free (I know GeoLite2). The html5demos.com/geo fails to find my location. – jsurf Jun 01 '16 at 11:58