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: ID
Liquid Tag: {{ session.current_user.id }}
Item Name: ID of the user

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

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

Field Name: First Name
Liquid Tag: {{ session.current_user.first_name }}
Item Name: first name of user

Field Name: Last Name
Liquid Tag: {{ session.current_user.last_name }}
Item Name: last name of user

Field Name: Created At
Liquid Tag: {{ session.current_user.created_at }}
Item Name: date user was created

Field Name: Updated At
Liquid Tag: {{ session.current_user.updated_at }}
Item Name: date user was last updated

Field Name: Last Edit Date
Liquid Tag: {{ session.current_user.last_edit_date }}
Item Name: date user was last updated

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

Field Name: Secure Zones
Liquid 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'] }}.


Did this answer your question?