php - Shared hosting - catch user ip -


i hosting 1 site @ ccihosting.com , tried catch user ip with

$_server['remote_addr'] 

and got ip of server located in panama not ip. told me because of shared hosting. webhostings have shared servers don't ? , got no problems of catching ip addresses. know whther because of shared hosting or no.

thanks

ip address of website differ on shared hosting. many websites on shared hosting may have different dns names same ip addresses.

you same ip address when on dedicated hosting server.

edit : try alternative code

<?php function get_client_ip() {     $ipaddress = '';     if (getenv('http_client_ip'))         $ipaddress = getenv('http_client_ip');     else if(getenv('http_x_forwarded_for'))         $ipaddress = getenv('http_x_forwarded_for');     else if(getenv('http_x_forwarded'))         $ipaddress = getenv('http_x_forwarded');     else if(getenv('http_forwarded_for'))         $ipaddress = getenv('http_forwarded_for');     else if(getenv('http_forwarded'))         $ipaddress = getenv('http_forwarded');     else if(getenv('remote_addr'))         $ipaddress = getenv('remote_addr');     else         $ipaddress = 'unknown';      echo $ipaddress; }  get_client_ip(); ?> 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -