Wierd Logout Problem

Hi Modxers

I’m running Modx Revo 2.7.3 and currently using “Login” and “Wayfinder” extras on my website to build customised content relating to the user that logs in.

So I don’t appear to have problems with the user(s) logging in and seeing their respective content only. It’s working okay as far as I know.

Where i’m having problems is logging the user out. My Wayfinder Chunk gives me a logout link as per below, which when clicked, follows through to a logout and I arrive at the login page.

<!--innerTpl-->
<div id="menu">
    <ul>
             [[+wf.wrapper]]
             <li><a href="[[~1&service=logout]]">Logout</a></li>
    </ul>
</div>

Above resource ~1 is the “login page” with following snippet call for login extra:

[[!Login?
&loginTpl=`lgnLoginTpl`
&logoutTpl=`lgnLogoutTpl`
&errTpl=`lgnErrTpl`
&loginResourceId=`9`
&logoutResourceId=`10`
]]

When i try to log back in as another user, it authenticates and logs in, but as the previous user! So is there a problem with the logout not completely killing my session?

I’ve put the following code in the top of my template for the resource which acts as the entering page for all users. Even when i log in (successfully authenticating as another user) I see the previous user’s username and user id. Totally weird, has anyone come across this before?

[[+modx.user.username]]

[[+modx.user.id]]

Your logout link looks incorrect according to the docs, try

<a href="[[~1? &service=`logout`]]" title="Logout">Logout</a>

https://docs.modx.com/current/en/extras/login/login.tutorials/basic-setup

1 Like

Thanks PaulP

Code for the link was definitely wrong as you stated, but unfortunately even the correct link hasn’t changed the symptoms.

I’m thinking this has to be something to do with the session, when i go away for some time and log back in as the other user it successfully logs in as that user and I can see the username and id of the correct user i logged in as. So i’m guessing that is the session of the other user timing out in this case.

Thinking the logout process somewhere isn’t completely killing the session? So weird that the successful authentication of one user logs in as another. Currently 2 users. I’ve got the same symptoms both ways (either user) when i log in as the first user, it just doesn’t seem to log out.

Thanks

I think, you have to call this placeholders uncached

Thanks Bruno, how would i do this if you don’t mind me asking?

https://docs.modx.com/current/en/building-sites/tag-syntax#caching

1 Like

Thanks Bruno, you are a miracle worker!

Uncaching the Wayfinder call, updated my menu with relevant resources
[[!Wayfinder?

Uncaching the resource call for logout fixed the logout problem I was having.

<!--innerTpl-->
<div id="menu">
    <ul>
             [[+wf.wrapper]]
             <li><a href="[[!~1? &service=`logout`]]" title="logout">Logout</a></li>
    </ul>
</div>

Many thanks to both you gentlemen! Saved me hours i reckon.