Skip navigation
cwhazzoo
Currently Being Moderated

Show user name if user is logged in?

Apr 8, 2009 8:55 PM

Hi,

 

I am having a very difficult time trying to get my pages to show if someone is logged on.

 

For example:

 

Welcome (username)

or

You are currently logged on as (username)

 

I want it to display their user name if the are logged on.

You can refer to the image I uploaded.

Please help.

 

Thanks.

Attachments:
 
Replies
  • Currently Being Moderated
    Apr 9, 2009 1:33 AM   in reply to cwhazzoo

    Create a session variable for the username then show the username by placing the session of the username into page from bindings tab.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2009 4:41 PM   in reply to cwhazzoo

    Hi cwhazzoo,

     

    in addition to what dwfaq.info suggests, it should be mentioned that ADDT makes it pretty easy to display a certain page region only if a user is logged in -- in your case I suggest to highlight the whole...

     

    Welcome {Session.kt_login_user}

     

    ...line and apply ADDT´s "Show If User Is Logged In" server behaviour (under "Conditional Regions") to it. This behaviour also comes with a helpful optional sub-feature named "has ELSE", which lets you specify an alternate text such as "you´re currently not logged in" in case, well, the user isn´t logged in.

     

    Cheers,

    Günter

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 9, 2009 4:57 PM   in reply to cwhazzoo

    cwhazzoo wrote:

     

    I currently dont have ADDT and I went to go look at it and Adobe is getting rid of it. Is there any way to do the same stuff just using Dreamweaver CS4 without having to know complex coding?

    nope, the required coding isn´t too complex -- but then again I think that questions which are not related to ADDT should rather be posted to the regular Dreamweaver forums (Application Development) and not in here ;-)

     

    Cheers,

    Günter

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 14, 2009 2:22 PM   in reply to cwhazzoo

    If you are looking for something similiar to the login features that ADDT had, check out www.webassist.com for their security extension. It will do the same thing but is a bit harder to use.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 28, 2009 7:34 PM   in reply to cwhazzoo

    U can just simply using the session. For example, you can put like this if you are using PHP programming language.

     

    Hello <?php echo $_SESSION['MM_Username']?> !

     

    But make sure u put this code at the begining of your code.


    if (!isset($_SESSION)) {
      session_start();
    }

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 28, 2009 8:35 PM   in reply to cwhazzoo

    In dreamweaver, switch to the code view. put the code at the first line or below the <?php require_once('../Connections/.. ); ?> if u have database connection. Make sure the code is in PHP tag <?php like below:

     

    <?php
    //initialize the session
    if (!isset($_SESSION)) {
      session_start();
    }

     

    .....

    //any of your is here

     

    ?>

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 28, 2009 8:41 PM   in reply to cwhazzoo

    What do u mean dreamweaver doesn't have that?? When u try to create login form, you must do the Log In User under Server Behaviour. This will automatically produce the code that consists of MM_Username. Try to do that and you can see this kind of code

     

        //declare two session variables and assign them
        $_SESSION['MM_Username'] = $loginUsername; <-- the username of user
        $_SESSION['MM_UserGroup'] = $loginStrGroup;  <-- the access level of user if u create one in your registration form

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 28, 2009 8:45 PM   in reply to cwhazzoo

    It's okay. Glad you have got the answer.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 28, 2009 8:57 PM   in reply to cwhazzoo

    Ok, if u got any problem then just post your code here. Maybe I can fix from that. Good luck

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 18, 2009 8:44 AM   in reply to Günter Schenk

    Thank you Günter,

    Your input helped me solve an issue I really did sweat quite a bit on.  This is wonderful support, and I do hope Adobe is not going to give up such a service!

    Thank you.

     

    A-PP

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 22, 2009 1:00 PM   in reply to cwhazzoo

    use session variables for that, start ur session and declare username in session variable and use it anywhere..

     

    Thanks

    pagerankplace.com

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 13, 2010 11:32 AM   in reply to QiQi86

    Hey QiQi86... i want the same thing but it is not working with me. Also this page does not have any log out or restrict acces to codes.

     

    Basically this is a public page but i want an 'edit' link beside any entry which should only be visible to the admin (i.e if logged in)

     

    So i simply add session start and then if(isset($_SESSION['MM_Username'])) {echo $row_codeSamples2['id'];}

     

    and nothing else related to the admin session.. also this page is not directly related to any admin page so is it possible that the var gets lost in between, when there is no session code. If yes then what should i add to every other page (for now 1) which comes in between.

     

    i cand code php well but sessions knowledge is a bit weak. Plz help thanks

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 13, 2010 1:22 PM   in reply to Achin Sharma

    Maybe u can try change the code like this

     

    if(isset($_SESSION['MM_Username'] == 'Administrator'))

     

    where the Administrator must referring to the administrator username (ex: Administrator/administrator/admin/etc..)

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 13, 2010 4:00 PM   in reply to QiQi86

    Parse error: syntax error, unexpected T_IS_EQUAL, expecting ',' or ')'

     

    if i exactly put you code "if(isset($_SESSION['MM_Username'] == 'Administrator'))", no surprise... isn't it wrong to use isset with ==?? these are two different methods.. aren't they??

     

     

    and if i try if($_SESSION['MM_Username'] == 'Administrator')

    it still does not work..

     

    Do i need to post any more code.. coz i really dont think any code could be posted..

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points