How to get userid from web server

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phillip Wu

    How to get userid from web server

    I have a javascript program that lives in the secure part of a web
    site.

    In order to get access to this java program the user needs to log in
    providing a userid and password. I understand that the userid/password
    is verified by the web server (Apache in my case). I also understand
    that any server side program written in php can get the userid from
    environment variables.

    I want to be able to find out the userid that the user logged in as,
    from my javascript program (client side).

    I know that it would be a breach of security to get the user's
    password. I cannot see any security concerns in getting the userid.

    How do I get this information - is there an object I can query?

    If I cannot get it I suppose the best thing to do was to get the
    server side php to put the information into a cookie that the
    javascript can read. Is this the best way?

    Thanks for any help.
  • Marco Dieckhoff

    #2
    Re: How to get userid from web server

    In article <943cec75.03081 32201.3f8dcf22@ posting.google. com>, Phillip Wu wrote:
    [color=blue]
    > I have a javascript program that lives in the secure part of a web
    > site.
    >
    > In order to get access to this java program the user needs to log in[/color]

    Please notice: javascript has NOTHING do to with java (programs).
    [color=blue]
    > providing a userid and password. I understand that the userid/password
    > is verified by the web server (Apache in my case). I also understand
    > that any server side program written in php can get the userid from
    > environment variables.
    >
    > I want to be able to find out the userid that the user logged in as,
    > from my javascript program (client side).[/color]

    If you can use .php, put in your <script>-Section something like
    <?php print '$username = ' . $ENV['REMOTE_USER']; ?>

    (May be syntactically wrong, especially $ENV... :)
    [color=blue]
    > If I cannot get it I suppose the best thing to do was to get the
    > server side php to put the information into a cookie that the
    > javascript can read. Is this the best way?[/color]

    Why using a cookie when you can insert it to your code directly?

    --
    Marco Dieckhoff
    icq# 22243433
    GPG Key 0x1A6C95BA -- http://www.frankonia-brunonia.de/keys

    Comment

    Working...