# Problem with Login Button and wixUsers.logout( )

**URL:** <https://forum.wixstudio.com/t/problem-with-login-button-and-wixusers-logout/33200>\
**Category:** Ask the community\
**Tags:** wix-members-area, code, question\
**Created:** [December 30, 2017, 2:30am UTC](https://forum.wixstudio.com/t/problem-with-login-button-and-wixusers-logout/33200 "2017-12-30T02:30:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike-donovan](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mike-donovan/32/1365_2.png) [@mike-donovan](https://forum.wixstudio.com/u/mike-donovan)\
**Post date:** [December 30, 2017, 2:30am UTC](https://forum.wixstudio.com/t/problem-with-login-button-and-wixusers-logout/33200/1 "2017-12-30T02:30:09Z")

</div>

It appears that when the user logs out using the Wix Members login button, wixUsers.logout( ) is not called.

I put a breakpoint in my wixUsers.logout( ) code, and it was not reached.  
Can anyone confirm this?

---

<div class="post-metadata">

**Author:** ![asher](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@asher](https://forum.wixstudio.com/u/asher)\
**Post date:** [December 30, 2017, 8:54am UTC](https://forum.wixstudio.com/t/problem-with-login-button-and-wixusers-logout/33200/2 "2017-12-30T08:54:30Z")

</div>

Make sure you have the correct names for the login button. Such as the ID in it’s place or it won’t work properly. Look at this : [YouTube](https://www.youtube.com/redirect?q=https%3A%2F%2Fsupport.wix.com%2Fen%2Farticle%2Fhow-to-create-member-profile-pages-with-wix-code&redir_token=eAIm_nwSJVUeHBwtgzNKdmBpm4t8MTUxNDcxMDQzOEAxNTE0NjI0MDM4&v=Orl8GJNzG5s&event=video_description)

---

<div class="post-metadata">

**Author:** ![mike-donovan](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mike-donovan/32/1365_2.png) [@mike-donovan](https://forum.wixstudio.com/u/mike-donovan)\
**Post date:** [December 30, 2017, 9:23am UTC](https://forum.wixstudio.com/t/problem-with-login-button-and-wixusers-logout/33200/3 "2017-12-30T09:23:32Z")

</div>

I see that I was actually mistaken.

Originally I thought wixUsers.logout( ) logged the user out (which it does!)  
In the course of looking at documentation, I got the idea that if was a kind of handler, which would be called when a user has finished logging out. (Like a sister-function to onLogin( )).

Which leads me to the question … why is there no wixUsers.onLogout( ) function, which is called when the user finished logging out?

I am trying to change the appearance of some things like a “Profile” button and a user icon, when someone logs out, so that those things are no longer seen. You can’t do anything like that without an onLogout( ) as far as I am aware.

I had to resort to adding a setInterval( ) which checks every fraction of a second, if the user is still logged in, and if they are not, changes the graphical elements. This is woefully inefficient.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/system/32/86885_2.png) [@system](https://forum.wixstudio.com/u/system)\
**Post date:** [December 30, 2017, 6:23pm UTC](https://forum.wixstudio.com/t/problem-with-login-button-and-wixusers-logout/33200/4 "2017-12-30T18:23:37Z")

</div>

Hi Mike,

logout() return a function that is resolved when the user is logged out,  
You can use:

```javascript
wixUsers.logout()
  .then( ( ) => {
    console.log("User logged out");
  } )
  .catch( (err) => {
    let errorMsg = err; // "No member is logged in"
  } );

```

---

<div class="post-metadata">

**Author:** ![mike-donovan](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mike-donovan/32/1365_2.png) [@mike-donovan](https://forum.wixstudio.com/u/mike-donovan)\
**Post date:** [January 7, 2018, 6:12am UTC](https://forum.wixstudio.com/t/problem-with-login-button-and-wixusers-logout/33200/5 "2018-01-07T06:12:21Z")

</div>

Hi Liran,  
Does having the line wixUsers.logout() in your code _cause_ the user to be looged out immediately, or is does it only allow you to _handle_ a log out event?

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/system/32/86885_2.png) [@system](https://forum.wixstudio.com/u/system)\
**Post date:** [January 8, 2018, 8:46am UTC](https://forum.wixstudio.com/t/problem-with-login-button-and-wixusers-logout/33200/6 "2018-01-08T08:46:13Z")

</div>

Hey Mike,  
It does both.  
User is logged out and a promise is resolved (with no arguments):

```javascript
wixUsers.logout()
  .then( ( ) => {
    console.log("User logged out");
  } )
  .catch( (err) => {
    let errorMsg = err; // "No member is logged in"
  } );

```

Liran.

---

<div class="post-metadata">

**Author:** ![jbcruzortiz](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/jbcruzortiz/32/10667_2.png) [@jbcruzortiz](https://forum.wixstudio.com/u/jbcruzortiz)\
**Post date:** [September 9, 2024, 6:32pm UTC](https://forum.wixstudio.com/t/problem-with-login-button-and-wixusers-logout/33200/7 "2024-09-09T18:32:54Z")

</div>

I can assure that the event handler ‘authentication.onLogout()’ is running after click logout from the login bar. For website lang ES version runs but do not apply the change and the wixUser.currentUser.loggedIn still true and for that case trying to logout in there wixUsers.logout() runs in infinite cycle.
