Skip to content

Developers · Users and Permissions

Logging Out an Authenticated User

Last updated 1 November 2026

This guide helps you create an authentication form to log out authenticated users.

Prerequisites

To follow the steps in this tutorial, you should understand the required directory structure for your codebase and the concept of pages and users. In addition, you need to understand the difference between Production and Staging Instaces.

Steps

Logging out an authenticated user is a two-step process:

  • Step 1: Create a log-out form
  • Step 2: Embed the log-out form

Step 1: Create the Log Out Form

app/forms/log_out.liquid

---
name: log_out
resource: Session
---

{% form method: 'delete' %}
  <button>Log Out</button>
{% endform %}

The difference between logging in and logging out is that you want to destroy the session with the latter. You must send a request by providing the attribute to the tag.

Step 2: Embed the Log Out Form

app/views/pages/log-out.liquid

---
slug: log-out
---
<h2>Log out</h2>
{% include_form 'log_out' %}

Note

To set an expiration for user sessions, follow the steps outlined in the 'User Session Timeout' section of the Updating Instance Configuration tutorial.

Next Steps

Congratulations! You created a log-out for authenticated users. Now you can learn about resetting a user's password: Resetting the Password of an Authenticated User.