Drupal 7: How to get user’s IP or hostname ?

In Drupal 7 how to find out any guest user or registered user’s IP address or hostname?

The answer is we can use session_id() which is stored in the ‘session’ table in the D7. It can return current user’s IP address or hostname by using session-id whether user is a guest or registered member.
So I write a function you can find it here.

https://github.com/tanveer-noman/neeocis-wp-support/tree/master/drupal-how-to-get-hostname

Advertisements
%d bloggers like this: