cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Create Session Parameters

0% helpful (0/1)

 

Maintain cookies and security information by implementing session parameters in your application.

 

Guide Concept

 

This project will introduce creating and accessing session data from a User logged into your application. Session data is global session-specific parameters that can be used on the Client and Server side.

 

Following the steps in this guide, you will be able to access the logged in User's information and their set values.

 

We will teach you how to access session data, that can later be used to provide Users with unique experiences and a more robust application.

 

You'll learn how to

 

  • Create Session Data
  • Access Stored Session Data

 

NOTE: This guide's content aligns with ThingWorx 9.3. The estimated time to complete this guide is 30 minutes

 

 

Step 1: Completed Example

 

Download the completed files for this tutorial:  Sessions.xml.

 

The Sessions.xml file contains a completed example of session parameters. Utilize this file to see a finished example and return to it as a reference if you become stuck during this guide. Keep in mind, this download uses the exact names for entities used in this tutorial. If you would like to import this example and also create entities on your own, change the names of the entities you create.

 

 

  1. In the bottom-left of Composer, click Import/Export.
     

     

    select_import.png

  2. Click IMPORT.
     

     

    import_modal.png

  3. In the Import pop-up, keep the default values and click Browse.
  4. Navigate to the Sessions.xml file you downloaded. Select it and click Open.
  5. Click Import in the Import pop-up.
  6. Click Close to close the pop-up.

 

 

 

Step 2: Create Session Parameters 

  1. Click the Browse folder on the left-hand side.
  2. Under System, select Subsystems.
     

     

    open_subsystems.png

  3. Filter for UserManagementSubsystem and open it in Edit mode.
     

     

    filter_user_subsystem.png

  4. Select Services.
  5. Filter for the AddSessionShape Service.
     

     

    open_service.png

  6. Click the Play button to open the Execute window.
  7. Enter UserLogin (the provided ThingShape) as the name input field.
  8. Click Execute.
     

     

    execute_service.png

  9. Click Done.

     

    end_service.png

You've just created your first Session Parameter. These values are used for content held in a cookie for a website or information that might be static for the User or session.

 

Best Practice: For information that will be static for the entire application and not based on the session, use a database option or a stored value in a Thing.

 

 

 

Step 3: Access Session Parameters

 

  1. Click the Browse folder on the left-hand side.
  2. Under System, select Resources.

     

    open_resources.png

  3. Filter for CurrentSessionInfo and open it.

     

    select_current_resources.png

  4. Select Services.
  5. Filter for the GetGlobalSessionValues Service.
     

    open_resource_service.png

  6. Click the Play button to open the Execute window.
  7. Click Execute. You will notice the result is a list of the properties in the UserLogin ThingShape. Your result might differ from mine.
     

    see_global_service.png

  8. Click Done.

 

NOTE: There is a difference between Session parameters and Mashup parameters. Mashups can have input values that will be used for services or content of that Mashup ONLY. Session parameters are based on the user using the application in a session. This data will be accessible throughout the application and last until they have completed their usage. This guide shows how to create Session parameters that are considered global session parameters.

 

 

Step 4: Next Steps

 

Congratulations! You've successfully completed the Create Session Parameters guide, and learned how to:

  • Access a logged-in user's information and their set values
  • Use session data to provide users with unique experiences and a more robust application

 

Learn More

 

We recommend the following resources to continue your learning experience:

 

CapabilityGuide
BuildCreate Custom Business Logic
BuildData Model Introduction

 

Additional Resources

 

If you have questions, issues, or need additional information, refer to:

 

Resource Link
CommunityDeveloper Community Forum
SupportSession Parameter Help Center

 

Comments

The "Step 3: Access Session Parameters" didn't address how to use a session parameter in a service.

Version history
Last update:
‎Nov 14, 2022 10:25 AM
Updated by:
Attachments
Contributors