View Categories

IP2Location Sample Codes

126 Docs

Display Visitor’s Country Currency Using ASP and MS-SQL Database

Last Updated: October 5, 2018

E-commerce businesses often have to deal with customers from around the globe. However, some customers may have difficulty to convert...

Display Advertisement by Country Using PHP and MySQL Database

Last Updated: October 5, 2018

Online advertising is another way to promote company products. It’s very important to show the right advertisements to the right...

Display Advertisement by Country Using .NET Framework

Last Updated: October 5, 2018

Why display advertisement based on visitor’s country Online advertising is another way to promote company products. It’s very important to...

Redirect Web Visitors By Country Using ASP and COM Technology

Last Updated: October 5, 2018

Why redirect web visitors based on country There are times when it is useful to redirect a visitor to different...

Redirect Web Visitors By Country Using ASP and MS-SQL 2008 Database

Last Updated: October 5, 2018

Why redirect web visitors based on country There are times when it is useful to redirect a visitor to different...

Redirect Web Visitors By Country Using PHP and MySQL

Last Updated: October 5, 2018

Why redirect web visitors based on country There are times when it is useful to redirect a visitor to different...

Redirect Web Visitors By Country Using .NET Framework in C# or VB.NET

Last Updated: October 5, 2018

Why redirect web visitors There are times when it is useful to redirect a visitor to different default web page...

Redirect Web Visitors By Country Using .NET Framework in Nuget

Last Updated: October 5, 2018

How to get geolocation information and redirect based on IP address This article shows you how to get geolocation information...

Credit Card Fraud Prevention Using ASP and MS-SQL 2008 Database

Last Updated: October 8, 2018

Credit card fraud has become pervasive on the Internet. According to MasterCard International, account takeover fraud has increased by 369%...

Credit Card Fraud Prevention Using PHP and MySQL Database

Last Updated: October 9, 2018

Credit card fraud has become pervasive on the Internet. According to MasterCard International, account takeover fraud has increased by 369%...

Credit Card Fraud Prevention Using .NET Framework in C# or VB.NET

Last Updated: October 9, 2018

Credit card fraud has become pervasive on the Internet. According to MasterCard International, account takeover fraud has increased by 369%...

Determine Web Visitors Country of Origin in the Drop Down List using ASP and COM Technology

Last Updated: October 9, 2018

With the emergence of online technologies such as the Internet, people and businesses have increased their reliance and use of...

Determine Web Visitors Country of Origin in the Drop Down List using ASP and MS-SQL 2008 Database

Last Updated: October 9, 2018

With the emergence of online technologies such as the Internet, people and businesses have increased their reliance and use of...

Determine Web Visitors Country of Origin in the Drop Down List using PHP and MySQL Database

Last Updated: October 10, 2018

With the emergence of online technologies such as the Internet, people and businesses have increased their reliance and use of...

Determine Web Visitors Country of Origin in the Drop Down List using .NET Framework in C# or VB.NET

Last Updated: October 10, 2018

With the emergence of online technologies such as the Internet, people and businesses have increased their reliance and use of...

Display Visitor’s Local Time Using PHP and BIN Database

Last Updated: October 10, 2018

In this tutorial, we demonstrate you on how to display visitor’s local time based on their IP address using PHP...

Display Visitor’s Local Time Using VB.NET and MySQL Database

Last Updated: October 10, 2018

In this tutorial, we demonstrate you on how to display visitor’s local time based on their IP address using VB.NET...

Display Visitor’s Local Time Using C-Sharp and MySQL Database

Last Updated: October 10, 2018

In this tutorial, we demonstrate you on how to display visitor’s local time based on their IP address using C-Sharp...

Display Sunrise and Sunset Time Using PHP and BIN Database

Last Updated: October 10, 2018

In this tutorial, we demonstrate you on how to display visitor’s sunrise and sunset time based on their IP address...

Display Sunrise and Sunset Time Using VB.NET and MySQL Database

Last Updated: October 10, 2018

In this tutorial, we demonstrate you on how to display visitor’s sunrise and sunset time based on their IP address...

Display Sunrise and Sunset Time Using C-Sharp and MySQL Database

Last Updated: October 10, 2018

In this tutorial, we demonstrate you on how to display visitor’s sunrise and sunset time based on their IP address...

Importing IP2Location data into MongoDB and querying with PHP (IPv6)

Last Updated: October 11, 2018

Intro The aim of this guide is to demonstrate how to import IP2Location data (DB26 IPv6) in CSV form into...

Importing IP2Location data into Redis and querying with PHP (IPv6)

Last Updated: October 11, 2018

The aim of this guide is to demonstrate how to import IP2Location data (DB26 IPv6) in CSV form into Redis...

Importing IP2Location data into Amazon SimpleDB and querying with PHP (IPv6)

Last Updated: October 11, 2018

The aim of this guide is to demonstrate how to import IP2Location data (DB26 IPv6) in CSV form into SimpleDB...

Importing IP2Location data into DynamoDB and querying with PHP (IPv6)

Last Updated: October 11, 2018

The aim of this guide is to demonstrate how to import IP2Location data (DB26 IPv6) in CSV form into DynamoDB...

Importing IP2Location data into CouchDB and querying with PHP (IPv6)

Last Updated: October 11, 2018

The aim of this guide is to demonstrate how to import IP2Location data (DB26 IPv6) in CSV form into CouchDB...

Configure Country Access Control in CloudFront Using Java

Last Updated: October 11, 2018

In this example, we demonstrate you on how to obtain country code that is associated with an end user’s IP...

How to automate downloading, unzipping & loading of IP2Location DB24 data into Linux MySQL

Last Updated: October 11, 2018

Here is a guide for users to fully automate the updating of their IP2Location DB24 database. We will show how...

IP Address Lookup in Bulk Using PHP and MySQL Database

Last Updated: October 12, 2018

In this tutorial, we demonstrate you on how to lookup IP address in bulk using PHP programming languages and IP2Location...

IP Address Lookup in Bulk Using VB.NET and MySQL Database

Last Updated: October 12, 2018

In this tutorial, we demonstrate you on how to lookup IP address in bulk using VB.NET programming languages and IP2Location...

Display Visitor’s GeoLocation Using Web Service in C#

Last Updated: October 12, 2018

Geolocation is a great way to put relevant content to your web visitors and it is a technology that can...

Display Visitor’s GeoLocation Using Web Service in VB.NET

Last Updated: October 12, 2018

Geolocation is a great way to put relevant content to your web visitors and it is a technology that can...

How to use IP2Location GeoLocation with Nginx

Last Updated: October 14, 2018

Geolocation is important, regardless of whether you are a marketer, online business owner, advertiser and so on. We need geolocation...

How to display country flag using image sprite

Last Updated: February 27, 2019

Introduction In this tutorial, we will demonstrate how to use the image sprite that consists of 249 country flags for...

The redirection in Varnish using IP2Location data

Last Updated: June 27, 2019

Introduction Varnish is a web application accelerator that improves the overall online web performance. In a nutshell, it acts as...

How to redirect visitor on Flask using IP2Location data

Last Updated: September 10, 2019

Introduction Flask is a lightweight web framework written in Python which makes it easy to develop a web application. Developers...

How to import DB24 (IPv6) into MSSQL 2017

Last Updated: September 18, 2019

Intro This guide aims to demonstrate how to load data from the IP2Location DB24 (IPv6) CSV file into a Microsoft...

Importing IP2Location data into Oracle Database and querying with PHP (IPv4)

Last Updated: September 23, 2019

The aim of this guide is to demonstrate how to import IP2Location data (DB26) in CSV form into Oracle Database...

Importing IP2Location data into SQLITE and querying with C# (IPv4)

Last Updated: October 29, 2019

Intro The aim of this guide is to demonstrate how to import IP2Location data (DB26) in CSV form into SQLITE...

Using IP2Location .NET component in ASP.NET MVC with C#

Last Updated: November 19, 2019

Intro For this article, we will look into how to integrate the IP2Location .NET component within an ASP.NET MVC 5...

Blocking country visitors in ASP.NET MVC with C#

Last Updated: November 20, 2019

Intro For this article, we will look into how to use the IP2Location .NET Component to block website visitors in...

Importing IP2Location data into PostgreSQL and querying with PHP (IPv4)

Last Updated: December 5, 2019

Intro The guide will demonstrate how to import IP2Location data (DB26) in CSV form into PostgreSQL and then query the...

How to create map visualization in Kibana using IP2Location Data

Last Updated: December 10, 2019

You are able to create region maps via the Kibana Visualize Service. Region maps are thematic maps in which boundary...

Importing IP2Location data into Cassandra and querying with PHP (IPv4)

Last Updated: December 11, 2019

Intro The guide will demonstrate how to import IP2Location data (DB26) in CSV form into Apache Cassandra and then query...

How to create region maps display in Kibana

Last Updated: January 10, 2020

You are able to create region maps via the Kibana Visualize Service. Region maps are thematic maps in which boundary...

Using IP2Location Go Package in multi-threading codes

Last Updated: February 18, 2020

Intro Starting with the IP2Location Go Package version 8.3.0, is now possible to perform concurrent geolocation queries with the IP2Location...

Country visitors redirection with ASP.NET MVC and IP2Location Web Service

Last Updated: February 20, 2020

Intro With the IP2Location.io IP Geolocation API, websites running ASP.NET MVC 5 can easily detect the visitor’s country and redirect...

Importing IP2Location data into SQLITE and querying with C# (IPv6)

Last Updated: April 30, 2020

Intro The aim of this guide is to demonstrate how to import IP2Location data (DB26 IPv6) in CSV form into...

Importing IP2Location data into Oracle Database and querying with PHP (IPv6)

Last Updated: May 6, 2020

The aim of this guide is to demonstrate how to import IP2Location data (DB26 IPv6) in CSV form into Oracle...

How to automate downloading, unzipping & loading of IP2Location DB24 data into Linux MySQL (IPv6)

Last Updated: May 8, 2020

Here is a guide for users to fully automate the updating of their IP2Location DB24 IPv6 database. We will show...

How to import DB24 (IPv4) into MSSQL 2017

Last Updated: May 8, 2020

Intro This guide aims to demonstrate how to load data from the IP2Location DB24 CSV file into a Microsoft SQL...

Importing IP2Location data into PostgreSQL and querying with PHP (IPv6)

Last Updated: May 8, 2020

Intro The guide will demonstrate how to import IP2Location data (DB26 IPv6) in CSV form into PostgreSQL and then query...

Importing IP2Location data into IBM Db2 and querying with PHP (IPv4)

Last Updated: May 12, 2020

Intro The guide will demonstrate how to import IP2Location data (DB26) in CSV form into IBM Db2 and then query...

Importing IP2Location data into IBM Db2 and querying with PHP (IPv6)

Last Updated: May 12, 2020

Intro The guide will demonstrate how to import IP2Location data (DB26 IPv6) in CSV form into IBM Db2 and then...

Collection of IP2Location & IP2Proxy CSV data import articles

Last Updated: May 14, 2020

Intro IP2Location and IP2Proxy both provides data in the form of CSV files that can be easily imported into various...

Using CLR code in SQL Server 2017 to convert IPv6 to IP number

Last Updated: June 11, 2020

Intro One of the useful things in SQL Server 2017 is the ability to use any Common Language Runtime (CLR)...

How to connect IP2Location MongoDB Docker in Debian container

Last Updated: July 27, 2021

IP2Location MongoDB docker simplifies the efforts to setup up the geolocation database for IP lookup. In this tutorial, we are...

How to perform MySQL query with IP2Location CodeIgniter 4 Library

Last Updated: September 2, 2021

IP2Location CodeIgniter 4 Library is fully integrated with supporting MySQL query in the latest version. This new feature enables the...

How to automate download of firewall IP list into ipset

Last Updated: September 28, 2021

In our previous article, we had mentioned the Block Visitors by Country Using Firewall page. This page allows anyone to...

How to display country code in the Nginx log using the IP2Location Nginx module

Last Updated: November 22, 2021

Intro Nginx [engine x] is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy...

How to use IP2Location PHP Library in CodeIgniter 4

Last Updated: August 23, 2022

Introduction CodeIgniter 4 is one of the popular web frameworks to help web developer to easily and quickly develop a...

Importing IP2Location data into Cassandra and querying with PHP (IPv6)

Last Updated: August 24, 2022

Intro The guide will demonstrate how to import IP2Location IPv6 data (DB26 IPv6) in CSV form into Apache Cassandra and...

How to use IP2Location IP geolocation in Django

Last Updated: September 22, 2022

Django is a free and open-source Python-based web framework, and is one of the most popular web frameworks in the...

How to use IP2Location in Deno?

Last Updated: October 5, 2022

Deno is a runtime designed for JavaScript, TypeScript, and WebAssembly languages. It’s built based on the V8 JavaScript engine and Rust...

How to use IP2Location in R language?

Last Updated: February 2, 2023

R is a programming language that is widely used in statistical computing. It was created by Ross Ihaka and Robert...

How to use IP2Location.io PHP SDK in Yii

Last Updated: May 23, 2023

Yii is an open-source PHP web framework that aims to let the developers to create a website easily. It is...

How to use IP2Location and IP2Location.io Python SDK in Falcon

Last Updated: June 7, 2023

Falcon is a Python web framework that is weightless and efficient. Falcon was designed in such a way that it...

How to use IP2Location and IP2Location.io PHP SDKs in Slim

Last Updated: June 30, 2023

Slim PHP is a micro framework for PHP that simplifies web application development, offering essential features like routing and middleware,...

How to use IP2Location and IP2Location.io PHP SDKs in Lumen

Last Updated: July 3, 2023

Lumen is a micro framework for building web applications and APIs in PHP. It is based on the Laravel framework...

How to use IP2Location and IP2Location.io PHP SDKs in Flight

Last Updated: July 3, 2023

The Flight framework is a lightweight and fast PHP micro-framework that allows developers to easily build web applications with a...

How to use IP2Location and IP2Location.io PHP SDKs in Phalcon

Last Updated: July 4, 2023

Phalcon is a high-performance PHP web framework that focuses on speed and low overhead. It is implemented as a C...

Using DB11 IPv6 in MySQL: decimal vs binary fields

Last Updated: November 9, 2023

MySQL is a common relational database being used by our customers to store the IP2Location Geolocation data. In this article,...

IPv4 IP queries using IPv6 CSV data (DB11 LITE)

Last Updated: December 5, 2023

IP queries allows you to discover the geographical location of a specific IP address. Businesses use IP queries to enhance...

How to use IP2Location library in Ruby on Rails

Last Updated: November 22, 2024

Ruby on Rails, often referred to as Rails, is an open-source web application framework written in the Ruby programming language....

How to use IP2Location.io library in Ruby on Rails

Last Updated: November 22, 2024

Ruby on Rails, commonly known as Rails, is a powerful, open-source web application framework designed with the Ruby programming language....

How to use IP2Location SDK in Elixir

Last Updated: June 4, 2025

Intro Elixir is a dynamic, functional programming language designed for building scalable and maintainable applications. It runs on the Erlang...

Using IP2Location Dart in console project

Last Updated: September 11, 2025

Intro Dart is a client-optimized, object-oriented programming language developed by Google for building fast apps on multiple platforms, including mobile,...

Display Advertisement by Country Using ASP and MS-SQL 2008 Database

Last Updated: April 3, 2026

Online advertising is another way to promote company products. It is very important to show the right advertisements to the...

Display Advertisement by Country Using ASP and COM Technology

Last Updated: April 3, 2026

Display ads based on visitor origin country Online advertising is another way to promote company products. It is very important...

A Beginner’s Guide to ASN and Hands-On Lookup Tutorial

Last Updated: December 3, 2024

Introduction An ASN (Autonomous System Number) is like a unique ID for a network. It identifies a group of networks...

Using IP2Location.io Java SDK in a Maven project

Last Updated: June 8, 2023

The IP2Location.io Java SDK is a wrapper for 2 APIs; the first being the IP2Location.io Geolocation API and the 2nd...

How to use IP2Location and IP2Location.io PHP SDK in Laminas

Last Updated: June 7, 2023

Laminas is a powerful open-source PHP framework for creating web applications. It follows the MVC pattern, promotes code reusability, and...

How to use IP2Location.io PHP SDK in Symfony

Last Updated: May 24, 2023

Symfony is a PHP web application framework that is free to use and open-source. It was designed to help in...

How to use IP2Location.io PHP SDK in CakePHP

Last Updated: May 22, 2023

In this article, we will show you how to use IP2Location.io PHP SDK in CakePHP to retrieve the geolocation information...

How to use IP2Location.io PHP SDK in CodeIgniter

Last Updated: May 10, 2023

CodeIgniter is a popular PHP framework that allows developers to create web applications rapidly. It is known for its small...

How to use IP2Location.io PHP SDK in Laravel

Last Updated: May 9, 2023

Laravel is a popular PHP web application framework that provides developers with a range of useful tools and features for...

Calling IP2Location inside MATLAB

Last Updated: September 19, 2022

MATLAB is a programming platform designed specifically for engineers and scientists to analyze and design systems and products that transform...

IP2Location Kafka: Adding geolocation in Kafka

Last Updated: October 11, 2022

In this article, we’ll delve into how to add IP address data and determine the geolocation in Kafka. Apache Kafka...

Setup SSH login notification with IP geolocation

Last Updated: April 27, 2022

Server admins commonly use SSH to login to Linux servers. They will disable login via password due to the ease...

How to display the geolocation results on amChart map

Last Updated: April 9, 2020

There is a growing number of websites that display various geolocation information using an interactive map object, for example, an...

Geolocation Lookup Using Symfony and IP2Location BIN Database

Last Updated: November 13, 2019

This demo supports Symfony 4, 5, and 6. In this tutorial, we’ll show you how to perform geolocation lookup and...

How to use IP2Location in R Language

Last Updated: October 18, 2019

This tutorial demonstrates how to use the IP2Location library in the R programming language. We used RStudio, an open source...

Display the nearest cities from visitor’s IP address using PHP and MySQL

Last Updated: October 18, 2019

  Display the nearest cities can help users access relevant local information, such as weather updates, news, events, or businesses...

Creating autocomplete for city search using PHP and MySQL database

Last Updated: October 14, 2018

Geolocation is of significant importance in the current era, and it plays a pivotal role in various aspects of our...

How to use IP2Location filter plugin with Elastic Stack (Elasticsearch, Filebeat, Logstash, and Kibana)

Last Updated: October 14, 2018

Geolocation is important, regardless of whether you are a marketer, online business owner, advertiser and so on. We need geolocation...

Display San Francisco Bay Area

Last Updated: October 14, 2018

In this tutorial, we demonstrate how to extract Bay Area information based on their IP address using C#/VB.NET/PHP/Java programming languages...

Converting IP address ranges into Netmask format

Last Updated: October 14, 2018

In this tutorial, we will demonstrate you on how to convert IP address ranges into Netmask format. A netmask is...

Geolocate Fail2Ban IP Using IP2Location

Last Updated: October 14, 2018

This tutorial will show you how to retrieve the geolocation information for the banned IP addresses reported inside the fail2ban...

Converting IP address ranges into CIDR format

Last Updated: October 14, 2018

In this tutorial, we will demonstrate you on how to convert IP address ranges into CIDR format. What is CIDR...

Integrating IP2Location C Library With Go Programming Language

Last Updated: October 14, 2018

The aim of this guide is to demonstrate integrating the IP2Location C library within the Go programming language. In our...

Integrating IP2Location C Library With D Programming Language

Last Updated: October 12, 2018

The aim of this guide is to demonstrate integrating the IP2Location C library within the D programming language. In our...

Configure the IPv4 Address Deny Rule in IIS 7 Using VB.NET

Last Updated: October 12, 2018

The aim of this guide is to demonstrate how to programmatically configure the IIS 7 IPv4 address deny rules using...

Display a visitor’s geolocation information using API in PHP

Last Updated: October 12, 2018

Geolocation is a great way to put relevant content to your web visitors and it is a technology that can...

IP Address Lookup Caching Using ElastiCache Memcached

Last Updated: October 12, 2018

In this tutorial, we will demonstrate how to cache an IP2Location query with the help of Amazon Web Service ElastiCache....

Deploying IP2Location .NET component as a global object in ASP.NET using VB.NET

Last Updated: October 12, 2018

The aim of this guide is to demonstrate the deployment of the IP2Location .NET component as a global object in...

How to create custom report in Matomo to display geo location information

Last Updated: October 12, 2018

In this tutorial, we are going to share with you how to create a custom report in Matomo. In this...

How to Use IP2Location Database in Laravel Framework

Last Updated: October 12, 2018

This tutorial shows you on how to import IP2Location DB3 (IP-Country-Region-City) into a MySQL database server and retrieve the geolocation...

IP Address Lookup in Bulk Using C-Sharp and MySQL Database

Last Updated: October 12, 2018

In this tutorial, we demonstrate you on how to lookup IP address in bulk using C-Sharp programming languages and IP2Location...

How to automate downloading, unzipping & loading of IP2Location DB24 data into Windows MySQL

Last Updated: October 11, 2018

Here is a guide for users to fully automate the updating of their IP2Location DB24 database. We will show how...

Simple GeoDNS using BIND and IP2Location

Last Updated: October 11, 2018

Implementing Geo-aware DNS using BIND with IP2Location Database This article illustrates how to use the IP2Location IP-Country Database (DB1) to implement a...

Configure Country Access Control in CloudFront Using .NET

Last Updated: October 11, 2018

The following sample application gets the IP address of the end user and sends the IP address to the IP2Location.io...

Configure Country Access Control in CloudFront Using PHP

Last Updated: October 11, 2018

The following sample application gets the IP address of the end user and sends the IP address to the IP2Location.io...

Importing IP2Location data into CouchDB and querying with PHP

Last Updated: October 11, 2018

The aim of this guide is to demonstrate how to import IP2Location data (DB26) in CSV form into CouchDB and...

Importing IP2Location data into DynamoDB and querying with PHP

Last Updated: October 11, 2018

The aim of this guide is to demonstrate how to import IP2Location data (DB26) in CSV form into DynamoDB and...

Importing IP2Location data into Amazon SimpleDB and querying with PHP

Last Updated: October 11, 2018

The aim of this guide is to demonstrate how to import IP2Location data (DB26) in CSV form into SimpleDB and...

Importing IP2Location data into Redis and querying with PHP

Last Updated: October 11, 2018

The aim of this guide is to demonstrate how to import IP2Location data (DB26) in CSV form into Redis and...

Importing IP2Location data into MongoDB and querying with PHP

Last Updated: October 11, 2018

Intro The aim of this guide is to demonstrate how to import IP2Location data (DB26) in CSV form into MongoDB...

Display Sunrise and Sunset Time Using PHP and MySQL Database

Last Updated: October 10, 2018

Display Sunrise and Sunset Time Using PHP and MySQL Database In this tutorial, we demonstrate you on how to display...

Importing IP2Location data into Microsoft SQL Server 2008 R2 and querying with VB.NET (IPv6)

Last Updated: October 10, 2018

Importing IP2Location data into MSSQL (IPv6) The aim of this guide is to demonstrate how to import IP2Location data (DB26)...

Display Visitor’s Local Time Using PHP and MySQL Database

Last Updated: October 10, 2018

In this tutorial, we demonstrate you on how to display visitor’s local time based on their IP address using PHP...

Find Weather Forecast from IP Address

Last Updated: October 10, 2018

In this tutorial, I will present how to retrieve the weather forecast for your location based only on your current...

Find distance between 2 IPs using BASH

Last Updated: October 10, 2018

In this tutorial, we will show how to calculate the distance between 2 IPs using geographical coordinates provided by any...

Geolocate using HTML 5 Geolocation API and IP geolocation

Last Updated: October 10, 2018

Wireless Geolocation (HTML 5 Geolocation API) vs. IP Geolocation It is good that with the introduction of HTML 5, there...

Credit Card Fraud Prevention Using ASP and COM Technology

Last Updated: October 8, 2018

Credit card fraud has become pervasive on the Internet. According to MasterCard International, account takeover fraud has increased by 369%...

Display Visitor’s Country Currency Using PHP and BIN Database

Last Updated: October 5, 2018

In this tutorial, we demonstrate you on how to display visitor’s country currency based on their IP address using PHP...

Display Visitor’s Country Currency Using PHP and MySQL Database

Last Updated: October 5, 2018

Why display currency based on visitor location The number of companies moved their business online is increasing. Selling products to...

Scroll to Top