5

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?

6

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 M 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.