SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best practice for determining user's country?

    Good evening everybody. I am building a website that provides services based on user's location (country). Now I am looking for a solution that is commonly used by other websites. There are 2 options – one is that I let the user specify his/her country at the time of registration and other is that use an IP database to automatically determine user’s country. Now both these options have drawbacks. If I provide a country selectbox in the registration form, some users may select wrong country to misuse the service. And if I use some IP database then some users may complain about wrong country being assigned to their profile as all IP databases are not 100% accurate. So I need to know the best practice for determining user's country. Should I ask them to specify their country manually or should I use some IP database for this? Please suggest. Thank you.

  2. #2
    ¬.¬ shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Let the users specify, their location. It really is the simplest way.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    Grüße aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,078
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by logic_earth View Post
    Let the users specify, their location. It really is the simplest way.
    I agree with logic_earth, it's far more simple to let users decide.

    However, should you decide to use a third party solution, there was a thread discussing this yesterday: http://www.sitepoint.com/forums/show...IP-Based-Image

    Also note the third possibility proposed in that thread: http://php.net/manual/en/book.geoip.php

    Edit: Sorry, I see it wasn't A PHP specific question. Nonetheless, I am sure there will be similar options/services available for whichever language you choose.

  4. #4
    SitePoint Member
    Join Date
    Dec 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks logic_earth and Pullo for your comments. I understand that allowing a user to select his/her country is the simple solution but a user can specify a different country to misuse the system. E.g. somebody from China can select US and get details that are meant for US users. I do have an IP database subscription (monthly) but am not sure if it is 100% accurate and it may be possible that it generates a different country (say Canada instead of US) for some IPs. Anyhow thanks for your reply.

  5. #5
    SitePoint Mentor silver trophybronze trophy
    Mikl's Avatar
    Join Date
    Dec 2011
    Location
    Edinburgh, Scotland
    Posts
    1,607
    Mentioned
    66 Post(s)
    Tagged
    0 Thread(s)
    Why not do both? That is, let the user pick the country, but default to the country that you have detected. Or, tell the user that you have detected that they are in the relevant country, but give them the chance to change it.

    Neither of these methods will deal with the problem of abuse. But I don't see why that's an issue. You say that, for example, "somebody from China can select US and get details that are meant for US users". Why should that be a problem? Is the US information sensitive in some way? If so, then that could point to a bigger security issue with the site.

    Mike

  6. #6
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,653
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Or you are a US user who happens to be in china at the moment.

    The IP databases can be interesting -- they are just databases, there is not a numbering scheme somewhere that states what IP is in what locale. Country is probably more accurate, but if you happen to get a random class C for an event you can bet it is not in the "right" location according to the databases.

  7. #7
    SitePoint Member
    Join Date
    Jan 2013
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If someone uses Tool's like Mask Surf Pro, the IP address is wrong and also the country.

    Olaf


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •