WatsMyName
WatsMyName

Reputation: 4478

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

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

$this->input->ip_address();

This should return the ip address of the machine, if user has valid ip, or should return 0.0.0.0 if the user doesn't have a valid IP. But in my case it's returning neither.

It is returning just an unusual format.

::1

P.S. I'm checking it in my local computer.

EDIT :

Thanks all who commented. But still it is strange things going out here. I have two separate applications running in my same machine. Both applications are made in Codeigniter 2. The first one records 0.0.0.0 and the second one records ::1. Isnt both application should have returned same thing?

Thanks

Upvotes: 5

Views: 7173

Answers (2)

casaram
casaram

Reputation: 484

It may be worth checking if ::1 is present in your hosts file, and comment it out just to see if both of your applications then behave the same.

This thread has some useful info: http://codeigniter.com/forums/viewthread/205222

In particular

So your machine is running dual stack (which most modern OS’ses do these days), and when they do, they prefer IPv6 over IPv4.

Either remove IPv6 from your localhost interface, remove IPv6 support from your local webserver (have it only listen to your v4 address), [snipped]

Upvotes: 1

Tchoupi
Tchoupi

Reputation: 14681

::1 is a valid IP address.

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

Upvotes: 6

Related Questions