How to get host name, Operating system User.....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

How to get host name, Operating system User.....

Post by pcoder »

Hi,
How to get the User host, Operating System User host name using PHP.
And how to give unique session id for each login of user.
Thanks
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

The majority of this question can be answered by the $_SERVER variable;

Code: Select all

echo '<HR><PRE>'; print_r($_SERVER); echo '</PRE>';
User avatar
dhrosti
Forum Commoner
Posts: 90
Joined: Wed Jan 10, 2007 5:01 am
Location: Leeds, UK

Post by dhrosti »

http://uk2.php.net/manual/en/reserved.v ... les.server explains the $_SERVER superglobal, where you can find user info.

As far as i'm aware, a unique session id is autmatically generated for you, accessed through the 'SID' constant.
User avatar
pcoder
Forum Contributor
Posts: 230
Joined: Fri Nov 03, 2006 5:19 am

Post by pcoder »

Is it possible to get the host name of client computer?
User avatar
dhrosti
Forum Commoner
Posts: 90
Joined: Wed Jan 10, 2007 5:01 am
Location: Leeds, UK

Post by dhrosti »

Code: Select all

// Host name. This might need setting up though, the details are in the link i gave you.
$_SERVER['REMOTE_HOST'];

// IP address of client.
$_SERVER['REMOTE_ADDR']; 

//Or...
$hostName = gethostbyaddr($_SERVER['REMOTE_ADDR']);
Post Reply