When using Dreamweaver's Log In User server behavior, you may want to use the user name on the very next page (the "redirect page") or on other pages in your web application. Some reasons you may want to pass the user name onto other pages include:

  • You want to greet the user after logging in. For example: "Hello John!"
  • You want to filter a recordset based on the user name in order to personalize the page.
  • You want to insert the user name into a form field to be used for inserting, updating or deleting a record.

The Log In User server behavior automatically generates a session variable consisting of the user name for the user when they log in successfully. The session variable for the user name is labeled "MM_Username".

Note: A second session variable is also automatically generated containing the user's authorization level, should you need to use this information on other pages. This session variable is named "MM_UserAuthorization".

Defining the MM_Username session variable as a data source for your pages

To utilize the MM_Username session variable on the pages in your site, open the login page in Dreamweaver. Open the Bindings panel. Click the plus (+) button and choose Session Variable from the pop-up menu. In the dialog box that pops up, enter "MM_Username" (without the quotes) in the name field. Click OK. Expand the Session icon that appears in the Bindings panel. The newly defined data source should appear, with a yellow lightning bolt icon next to it.

Using the MM_Username session variable in your pages:

  • Displaying the user name on successive pages:
    To display the user name on any of the successive pages, open the page where you want to display the user name. Open the Bindings panel and drag the MM_Username session variable on the page in Design view. This will cause the session variable contents to be written to this page.
  • Filtering a recordset based on the user name:
    Open the page where you want to create the filtered recordset. To filter a recordset based on the session variable, go into the simple view of the Recordset dialog box, and set the filter to:"[myUsernameField] = Session Variable MM_Username", where"[myUsernameField]" is the name of the database field holding the user names. The advanced view of the Recordset dialog box should be used if you are filtering on multiple variables or if you need to use a more complex SQL statement.
  • Setting a form field's value equal to the user name:
    Open the page that contains the form. To set a form field's value equal to the session variable, select the text field form element on the page. Go to the Property inspector > click the Attributes tab in the upper left corner > click the plus (+) button > choose "value" from the drop-down menu > click the yellow lightning bolt icon > choose the MM_Username session variable.

Additional information

If you would like to pass form data other than the user name from your login page, please refer to How do I create a session variable? (TechNote 14791) for detailed information on creating session variables.

For an explanation of why session variables should be used to pass form data from a login page to successive pages, please refer to: How to pass form data from an insert, update or delete page (TechNote 15239). Though the TechNote discusses the insert, update and delete server behaviors, the mechanics are similar for the Log In User server behavior.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy