Functions like getlogin and getpwuid return the info for the user running the script. When you run the script at the command line, the user is you. When the web server runs the script as the request of an HTTP request, the user is the one your web server is configured to run as -- in this case, www-data.

What current login name are you trying to get? There are many methods you can use to require visitors to your web site to login, from basic HTTP authentication using .htaccess/htpasswd (which will put the username in $ENV{REMOTE_USER}), to form- and/or cookie-based session/login systems that are common in many frameworks. Each of these will provide the username in a different way, so it will depend on what login system you use.


In reply to Re: Get the currently logged in User name by aaron_baugher
in thread Get the currently logged in User name by irah

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.