PricingDocsAcademy
Bluesky ...
Wed, Dec 11, 10:29 PM

Knowing a session expired

  • benjabievres

    28 days ago

    Hello dear community,

    I would like to detect when a session cookie has expired and redirect the user to the login page; can this be achieved?

    And if I create a logout button, how can I clear the session cookie?

    Thanks!

    Ben
  • Lucas G

    28 days ago

    That depends on the backend you use. Supabase for example has an auth endpoint that returns the user which returns an error if there’s no session (expired)
  • Lucas G

    28 days ago

    You can use the Set Session Cookies action to clear cookies as well. Just set the token field to an empty string
    👍1
  • benjabievres

    28 days ago

    @Lucas G thanks for this answer. In fact for the moment it’s me that implemented my little idp (with Make), so maybe I should keep the hour of the session and send a 401 when it has expired, right?
    And in that case do I handle the redirect when I get an error 401 from the API call in Toddle?

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.