I have developed a simple registration page and given this page access to users through a force.com site. How can I store the visiting user's IP address in Salesforce?
Following may help:
String clientIP = ApexPages.currentPage().getHeaders().get('True-Client-IP');
if(clientIP == null || clientIP == ''){
clientIP = ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');
}
-
Hi San Tosh, Thank You for your help, it's woking fine. i have another question based on IP Address how we can get the Address (Street, City ,Country) information. Please help on this. i Relly Appreciate your help – Murali Mohan Mandadi Sep 9 '15 at 12:21
-
This can only be done by external API. you could use latitude and longitude for finding this. Pass the data to Google Maps API and it returns the address. – San Tosh Sep 10 '15 at 2:31