Skip to main content
1-Visitor
July 25, 2014
Question

How to maintain session across tabs/pages in Mashup

  • July 25, 2014
  • 2 replies
  • 1263 views

Hi,

I am developing a Thingworx Mashup which has a login page and once logged in, pages with specific content will displayed based on the logged in user. Login authentication will be done based on database.Please let me know how to maintain login session of logged-in user across all tabs/pages in a mashup? Is there any standard method defined by ThingWorx? If so please share the related tutorial link.

 

Regards,

Raj


 

    2 replies

    19-Tanzanite
    July 25, 2014

    Hi Raj,
    In the Mashup Composer, on the right side of page you have the Data, Session and User sections.
    If
    you switch to the User tab, you have the name of user and you can bind
    to any control accepting String binding, or perform specific services that take this input as a parameter.

    If, however, you want to make thing simpler, you can
    invoke the following function in any service, in order to obtain the
    currently logged user:
    var userName = Resources["CurrentSessionInfo"].GetCurrentUser(); //STRING


    BR,
    Vladimir



    5-Regular Member
    July 28, 2014

    Raj,

    Are you looking to display different

    Mashups

     based on the current user or just user-specific content? If it's the latter, you can also use the "principal" keyword which is functionally equivalent to

    GetCurrentUser()

    . It's a nice shorthand that will save you some typing ; )


    If it's the former, you'll need some logic in your

    Mashups

     to determine which

    Mashup

     should be displayed for the current user. Most likely, you'll use a

    Contained Mashup

     and dynamically bind the name of a

    Mashup

     depending on the current user.


    Regards,

    Adam