Connect with us

How to get real Client IP address in php (stop using $_SERVER['REMOTE_ADDR'] )

kizinho

Published

on

Follow
NEWS: How to get real Client IP address in php (stop using $_SERVER['REMOTE_ADDR'] ) [New  Developer] » Naijacrawl
Photo: Naijacrawl
site

Hi guys today will point out on how to use real user IP , incase you want to use it do a lot of things on your website.

 

Using the below code to find a client IP address is very bad.

 

$_SERVER['REMOTE_ADDR'] 

 

I have fallen a victim the time i used it to do a lot of things like, using Client IP for tracking pageviews, blacklisting and voting, but at the end it didn't work as i excpeted  .

 

What  $_SERVER['REMOTE_ADDR']  does is to collect the real IP of your hosting instead of an IP per a user.

 

I could remembered the time i used it before i switched on using cookies, which works very well, but now have found a best way you can get real user IP.

This is the only method for now that works, and don't try it when working offline , always do it on live server 

How to get real user IP

i recommended using below code to get your real user IP 

What HTTP_CF_CONNECTING_IP does is to collect the real ip of a user that is making a request to the server.

See working example here : Click to view it

 

You can change your IP using IP changer when testing it and also test for 

You will see that your IP will be the same when using this method.

 

If this article help , kindly share it and drop a question on the comment box.

Happy coding 

Click Here To Comment


site


kizinho

Adike Kizito is a top-rated software developer, blogger, sports, and entertainment lover. He is the CEO of these popular websites Naijacrawl.com and Mp3ager.com. He operates his software developing task through Kizzsoft.com,... Read More

Continue Reading
Click to comment

Be first to comment


    Leave a Reply

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

    Latest


    Download Naijacrawl App today

    Fastest way to read on the go

    Download the Naijacrawl App.