I found the following website can detect my country and currency even in the private mode
http://www.innisfreeworld.com/
It records in cookie, How do it do that?
Is that possible fulfill in client site ? navigator?
Look up the IP address, with an IP geolocation service like Maxmind GeoIP. This is the location the request is coming from, i.e. if an American vacations in Italy and uses a Swedish VPN, it will return Sweden .
If the browser supports it, you can request the user's location from the Geolocation API using the getCurrentPosition function. window. navigator. geolocation .
You can use https://ip-api.io for this task easily.
The Geolocation API is accessed via a call to navigator. geolocation ; this will cause the user's browser to ask them for permission to access their location data. If they accept, then the browser will use the best available functionality on the device to access this information (for example, GPS).
There are multiple options to determine the locale. In descending order of usefulness, these are:
Sweden
.It can only be done with the help of the server. The main advantage is that it's very reliable. The accuracy will be country or region for free services, city or region for paid ones.
The answer will be very precise, usually no more than 10m off. In principle, it could work client-side, although you may want to perform the coordinate -> country lookup on the server. The main disadvantages are that not all devices have either GPS or WiFi position, and that it generally requires explicit user consent.
Accept-Language
header on the server (or with the help of the server), and extract the locale information. An American vacationing in Italy using a Swedish VPN will register as USA.The downside is that this is a setting that's extremely easy to change. For instance, English speakers around the world may prefer en-US
settings in order to avoid machine-translated text. On modern browsers (as of writing not IE/Edge, and only Safari 11+), you can also request navigator.languages.
navigator.language
is the first element of the navigator.languages
header. All of the considerations of navigator.languages apply. On top, this information can sometimes be just the language without any locale (i.e. en
instead of en-US
).
Use another, third-party service. For instance, if the user signs in via a Single-Sign-On system such Facebook connect, you can request the hometown of the user. This information is typically very unreliable, and requires a third party.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With