Logging Out an Authenticated User

Last edit:  Nov 21, 2018

Contributors:  lemingos

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

Requirements

To follow the steps in this tutorial, you should be familiar with the required directory structure for your codebase, and understand the concept of pages and users.

Steps

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

Step 1: Create log out form

marketplace_builder/form_configurations/log_out.liquid


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

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

The difference from logging in, is that you want to destroy the session. You have to send a DELETE request by providing the method: delete attribute to the form tag.

Step 2: Embed the log out form

marketplace_builder/views/pages/log-out.liquid


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

Next steps

Congratulations! You created a log out for authenticated users. Now you can learn about resetting a user's password:

Questions?

We are always happy to help with any questions you may have. Check out our Help page, or contact us.