getlogin
Returns the current login from /etc/utmp (Unix systems only), if any. If null, use getpwuid. For example:
getpwuid
$login = getlogin || getpwuid($<) || "Intruder!!";
18.118.149.19