Blog pribadi untuk curhat, share tentang script, software, kuliah, project IT dan seputar IT.

Get Windows username of current user using php

Tidak ada komentar
Jika anda menggunakan IIS maka anda perlu menggunakan

$_SERVER['LOGON_USER']
$_SERVER['AUTH_USER']
$_SERVER['REDIRECT_LOGON_USER']
$_SERVER['REDIRECT_AUTH_USER']

Jika anda menguunakan apache untuk mendapatkan path C:\\users\\\\desktop
maka anda bisa menggunakan cara ini, cara ini saya ambil dari stackoverflow

If by current windows user you mean the user running the script then that is set in an environment variable which you can get using:
< ?php echo getenv("username"); ? >
If you want to get the home directory of the user running the script you should use
< ?php echo getenv("HOMEDRIVE") . getenv("HOMEPATH"); ? >
This should output either C:\Users\Fred or C:\Documents and Settings\Fred depending on if you are using windows Vista/7 or windows XP.

To see all of the environment variables you can do:
< ?php global $_ENV; var_dump($_ENV); ? >



Tidak ada komentar :

Posting Komentar