Introduction

There are two main ways to access information about the currently logged in User using Liquid:

  • Using the User Details Layout is useful if you need to output user details in a single location within a layout structure.
  • Using the session object, which is globally available across liquid files. This can be useful if, for example, you need to use logic in several places in a file to hide or show content based on a user's custom fields or Secure Zones.

In this article, we'll cover how you can use the session object.

Prerequisites

Your User must be logged into a Secure Zone in order for Session to contain information about them, use the following links to learn how to set this up:

Outputting the Session object

To output the Session object head to whichever Page/Layout you're working in, from here simply type {{session.current_user}}. We recommend you output this somewhere away from your other Page contents, or within <hr> elements.

Now log into your Secure Zone and view the Page, you should see all of the information about the Current User:

To view this data in a better format copy the whole object, and paste it into JSON parsing tool. See "Visualising the Object Tree" within our Getting Started with Liquid Dot Notation tutorial to learn more about handling JSON.

Now we've learned how to output and format our Current User's data, let's look at the fields available:

```Field Name: IDLiquid Tag: {{ session.current_user.id }}Item Name: ID of the user

Field Name: EmailLiquid Tag: {{ session.current_user.email }}Item Name: email of the user

Field Name: NameLiquid Tag: {{ session.current_user.name }}Item Name: full name user

Field Name: First NameLiquid Tag: {{ session.currentuser.firstname }}Item Name: first name of user

Field Name: Last NameLiquid Tag: {{ session.currentuser.lastname }}Item Name: last name of user

Field Name: Created AtLiquid Tag: {{ session.currentuser.createdat }}Item Name: date user was created

Field Name: Updated AtLiquid Tag: {{ session.currentuser.updatedat }}Item Name: date user was last updated

Field Name: Last Edit DateLiquid Tag: {{ session.currentuser.lastedit_date }}Item Name: date user was last updated

Field Name: Favourite ItemsLiquid Tag: {{ session.current_user['Favourite Items'] }}Item Name: array of user's favourite items

Field Name: Secure ZonesLiquid Tag: {{ session.current_user['Secure Zones'] }}Item Name: array of the user's secure zones```

You'll also be able to access CRM custom fields via {{ session.current_user['My Custom Field'] }}.

Related Articles