I’m saving the user’s IP addresses by saving the value of $_SERVER['REMOTE_ADDR'] in a MySQL database. Problem is that for both Firefox and Chrome $_SERVER['REMOTE_ADDR'] is ::1 (that means localhost in IPv6) and for IE and Opera is 127.0.0.1 (IPv4).
So, my questions are
-
Are IP versions browser-dependant? (I used to think it depended on
the computer) -
Should I create two fields in the database, one for IPv4 addresses and one for IPv6 ones?
-
Should I unify all IPs to IPv6? And how can I do this in PHP (if it’s even possible)?
Fairly obvious – your box is IPv6-enabled, Firefox/Chrome use IPv6 whenever available, while IE and Opera don’t (or it’s a off-by-default setting).
Store the address in a string that’s long enough to hold an IPv6 address.
No, ’cause in the general case you cannot.