OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Accessing tokens stored in localStorage from server-side

  • Thread starter Thread starter Alan Ari
  • Start date Start date
A

Alan Ari

Guest
I'm attempting to implement a logout function that runs on the server-side. This function currently only removes tokens stored in localStorage upon login, as shown below:

Code:
const logout = () => {
  localStorage.removeItem('accessToken');
  localStorage.removeItem('idToken');
};

However, this approach encounters an error since localStorage is inaccessible on the server-side.

Question: How can I effectively remove the accessToken and idToken stored in localStorage from the server-side?

In the context of Nuxt 3 and removing tokens from localStorage on the server-side, I haven't directly tried modifying localStorage because it's not accessible there.

What I expected: I expected the logout function to successfully remove the tokens (accessToken and idToken) from localStorage on the server after a successful logout, as it does on the client-side. This would effectively invalidate the user's session.

<p>I'm attempting to implement a logout function that runs on the server-side. This function currently only removes tokens stored in <code>localStorage</code> upon login, as shown below:</p>
<pre class="lang-js prettyprint-override"><code>const logout = () => {
localStorage.removeItem('accessToken');
localStorage.removeItem('idToken');
};
</code></pre>
<p>However, this approach encounters an error since <code>localStorage</code> is inaccessible on the server-side.</p>
<p><strong>Question:</strong>
How can I effectively remove the <code>accessToken</code> and <code>idToken</code> stored in <code>localStorage</code> from the server-side?</p>
<p>In the context of Nuxt 3 and removing tokens from localStorage on the server-side, I haven't directly tried modifying <code>localStorage</code> because it's not accessible there.</p>
<p><strong>What I expected:</strong>
I expected the logout function to successfully remove the tokens (<code>accessToken</code> and <code>idToken</code>) from <code>localStorage</code> on the server after a successful logout, as it does on the client-side. This would effectively invalidate the user's session.</p>
 

Latest posts

Top