Get IP Address and GeoLocation of Login User

Get IP Address and GeoLocation
If you have a web portal and you need to get the geolocation from an IP address of every user who has logged into your website, then you can do it very easily using simple PHP script.

Getting Geolocation will help you to identify user location. You can monitor the website traffic and behavior using this feature. This article dictates a PHP script for doing the same.

Get GeoLocation From an IP Address Of User

To get geolocation we are using ipinfo API service. Pass the user IP address as parameter and it will return the IP location details like IP address, Host name, City, Location etc..

Here is the full code to first get the IP address of logging user, then to get the location details for the IP address and finally to save the details into database (if required).

This simple PHP script can be easily integrated and modified as per your need. Use this script on your website to get exact Geolocation from an IP address of user.

Recommended Posts For You

About Manish Kumar

I am PHP web developer and blogger.

View all posts by Manish Kumar

Leave a Comment

Your email address will not be published. Required fields are marked *