top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to get server user in PHP?

+2 votes
224 views

I've been looking over the output from phpinfo to find a way to portably get the server user name. It is not obvious to me...

Can I get that from an $_ENV or $_SERVER value?

I have a web base cms system with a file editor and want to test for ownership of the files and directories
without having to hard code the server name.

I can get file owner ship but if I want to verify it is the server user account, I would do:
(pseudo code)

$_name = getOwner()
if($_name == < portable reference to server user name>)
 {
 // proceed
}

This would be for enhanced access permissions analysis. If a file is being written to by the server user (via php code) it would be helpful to determine that to forstall error message generation.

posted Feb 17, 2015 by Sanketi Garg

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
+3 votes

Any opensource code would be a great help :)

0 votes

I have a question about using a php user class and session variables. Let's say that I have managed to create a user class that finds a particular person from the database query.

As I move about the site from page to page it would be nice to be able to use the current user inside the user class without needing to re – look them up in the database multiple times

Q: so is there a way to combine the current active user in the class with session variables so that they can be used multiple times? If so, how would this work?

...