Not working logout button

Wappler Version : 5.1.2
Operating System : Windows 10
Server Model: PHP
Database Type: MySQL
Hosting Type: local

What do you think should happen?

It should log out and redirect, instead of readirecting only…

What actually happens?

It only redirects, but it doesn’t log out

Description

I have a really simply log in and log out webpage that I reproduced from https://docs.wappler.io/t/logout-create-a-working-user-logout-button/2851 following this steps really carefully.

This is my log in server sourrunded by conditions, and it works just fine:

It effectively redirects to another page that is effectevly protected from unauthorised users (as I have checked with an incognito window)

image

I havea logout button…

…and the related server connect:

As you can see, it redirects on success.

Here is the Logout API:

What is happening is that, if user clicks log out, he is redirected, but not logged out, as I can browse to the restricted webpage as if i where loged in.

I’ve checked really carefully the forum and tutorial, but I can’t see any issue.

Can anyone help me or this is a bug?

Just in case, I’ve read and studied post Logout not working on mobile 🔐

When you go back and browse to a page after logging out, have you tried refreshing the page just to make sure it’s not showing the cached version?

This might not be the issue cause but you should really be setting up your security provider in globals in newer versions:

In the older docs it was needed in every API action this is no longer required and after you define once in globals you just select it from there so no need to add a provider per API action just goes straight into the logout etc

Yup, I’ve tryied with CTRL + F5 and it is still logged in.

Besides, a restricted API stills brings data (tha it doesn’t if I am not logged in)

Thank you for replying :smiley:

Have you checked in the dev tools (browser console) in Applications and then Cookies to see if the cookie is still there when logging out? It looks like you’re setting a cookie every time you log in but that cookie should be removed when you log out.

I’ve done taht :frowning: - that was my first attempt.

Mmmm… is strange, but is working randomly…

Have you run the API script directly in your browser?

Can you remove the security provider from the login and logout action and just use the dropdown to select the provider you defined in globals it might be nothing but could be causing a issue this thread is looking related:

1 Like

Yes, and it seems to be working… So, that would mean that this API is not being executed.

Maybe should I check Reload checkbox?

But it is strange, because if that API is not executing, the browser should not redirect:

Besides, It seems to be working randomly…

Finally solved this issue: it was me: making this server connection load inside a link, so it was trying to loading the link (#) instead of the server connect. Make it a paragraph and worked fine!

Thank you all!

You can just use a regular button, not a link.