Reading User Name

Discussion in 'Customization & add-ons' started by softstor, Aug 4, 2006.

  1. softstor

    softstor New Member

    Joined:
    Mar 1, 2006
    Messages:
    27
    Using php code in a seperate webpage, is it possible to read the user name that is presently logged in?
  2. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    On a separate webpage you cannot access other domain cookies and any info from other site is not available.
  3. softstor

    softstor New Member

    Joined:
    Mar 1, 2006
    Messages:
    27
    This would be in the same domain as amember.

    I would like to create a mysql database and use the user name as the key field in this database. Is it possible to retrieve the user name?
  4. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    <?php
    session_start();
    $member_id = $_SESSION['_amember_user']['member_id'];
    ?>

    I recommend use numeric member id instead of login.
  5. softstor

    softstor New Member

    Joined:
    Mar 1, 2006
    Messages:
    27
    Thanks for the info.

    It looks like you are using sessions. Is there any situition that the above code would not work?
  6. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    yes, if you change session settings in your script, or jump between
    www.yoursite.com/url and yoursite.com/url

Share This Page