Codeigniter 2 $ this-> ip_address () does not return ip address

Well, I'm trying to log in the login history, so for this I need to track the user's IP address. I used:

$this->input->ip_address(); 

This should return the ip address machine if the user has a valid ip, or should return 0.0.0.0 if the user does not have a valid IP address. But in my case, he did not return.

It returns only an unusual format.

 ::1 

PS I am checking it on my local computer.

EDIT:

Thanks to everyone who commented. But there are strange things here. I have two separate applications running on my machine. Both applications are created in Codeigniter 2. The first writes 0.0.0.0 , and the second writes ::1 . Shouldn't both applications return the same thing?

thanks

+4
source share
2 answers

::1 is a valid IP address.

http://en.wikipedia.org/wiki/IPv6

+6
source

It might be worth checking if :: 1 is present in your hosts file, and comment on it to make sure that both of your applications behave the same.

This thread has helpful information: http://codeigniter.com/forums/viewthread/205222

In particular,

So, your machine works with two stacks (which currently work with most modern OSs), and when they do, they prefer IPv6 over IPv4.

Remove IPv6 from your localhost interface, remove IPv6 support from your local web server (ask him only to listen to your v4 address), [snipped]

+1
source

Source: https://habr.com/ru/post/1433225/


All Articles