How to check if the session is authenticated when using cacheLocation memory?

My application has 2 major routes (auth route and unauth route).

When an user lands from auth to unauth route, I need to test whether the user is authenticated in order to handle some specific cases.

I’m using @auth0/auth0-spa-js and using these params to create an auth0 instance:

import { createAuth0Client } from ‘@auth0/auth0-spa-js’;

const auth0Client = yield createAuth0Client({
domain: ‘domain’,
clientId: ‘clientId’,
cacheLocation: ‘memory’,
authorizationParams: { audience: ‘audience’, redirect_uri: ‘redirect_uri’ }
});

PS: Using cacheLocation: ‘localStorage’ works fine, however I cannot use it for security reasons.

Thank you in advance.

Hi @elton.ea,

Welcome to the Auth0 Community!

You can check using isAuthenticated: Auth0Client | @auth0/auth0-spa-js

Or check the session using checkSession: Auth0Client | @auth0/auth0-spa-js

Hope this helps!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.