Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
Hi all, i´m currently testing an playing with the members module and all works great until i try to logout i can see in the login.php code that this template also handles 'logout', i can see too that the original code check if the user is logged in and then test if action='logout' then process logout else go to homepage. So every time i visit login.php while logged in as member i´m redirected to homepage:
Code: Select all
<cms:if k_member_logged_in>
    <!-- this 'login' template also handles 'logout' requests. Check if this is so -->
    <cms:set action="<cms:gpc 'act' method='get'/>" />
   
    <cms:if action='logout' >
        <cms:member_process_logout />
    <cms:else /> 
        <!-- what is an already logged-in member doing on the login page? Send back to homepage. -->
        <cms:redirect k_site_link />
    </cms:if>
<cms:else />

........

</cms:if>


i tried hardcoding the 'member_process_logout' to automatically logout when template is visited in two ways:
Code: Select all
<!-- method 1 if user logged in automatically process the logout-->
<cms:if k_member_logged_in >
    <cms:member_process_logout />
<cms:else />
    ......
</cms:if>

<!--method 2 if user logged in check for action='logout' but process the logout either way-->
<cms:if k_member_logged_in >
    <!-- this 'login' template also handles 'logout' requests. Check if this is so -->
    <cms:set action="<cms:gpc 'act' method='get'/>" />
   
    <cms:if action='logout' >
        <cms:member_process_logout />
    <cms:else /> 
        <cms:member_process_logout />
    </cms:if>
   
<cms:else />
    ......
</cms:if>


In the two cases i get this message on the browser:
Security tokens do not tally for executing this action. Please try again

Is there something i´m doing wrong here or is there another way to logout i´m not seeing??
Hi,

Please place the following on the other templates of the site where you want to give a logged-in user the option to logout -
Code: Select all
<a href="<cms:member_logout_link />">logout</a>

No need to amend the login template.

This piece of code is used in the 'members/profile.php' sample template but I'll also update the original thread to mention more clearly how to code the 'logout'.

Thanks.
Great! so simple thanks KK!
You are welcome :)
When i do this,
Code: Select all
<a href="<cms:member_logout_link />">logout</a>
it wont allow me to logout. hover over the page it shows javascript;void












Code: Select all
<cms:member_check_login />
<cms:if k_member_logged_in >
<cms:pages masterpage=k_member_template id=k_member_id >
<div id="nav-wrapper_124_1">
<div id="nav-wrapper_124_center">
<div id="profile_login111">
  <cms:show k_member_title /></div>
  <div style="float:left;"><img src="../img/spacetop.jpg" width="10" height="50"></div>
 
<cms:if account_type='Administration' >
<div id="profile_login112"><a href="http://tsmsport.co.uk/members/profile.php" style="color:#6B8E9C;">Home</a></div>
<div id="profile_login112"><a href="http://tsmsport.co.uk/members/profile.php" style="color:#6B8E9C;">Profile</a></div>
<div id="profile_login112"><a href="http://tsmsport.co.uk/members/edit_profile.php" style="color:#6B8E9C;">Edit</a></div>
<div id="profile_login112"><a href="<cms:member_logout_link />" style="color:#6B8E9C;">logout</a></div>
<cms:else />
<div id="profile_login112"><a href="http://tsmsport.co.uk/members/profile.php" style="color:#6B8E9C;">Profile</a></div>
<div id="profile_login112"><a href="http://tsmsport.co.uk/members/edit_profile.php" style="color:#6B8E9C;">Edit</a></div>
<div id="profile_login112"><a href="<cms:member_logout_link />" style="color:#6B8E9C;">logout</a></div>
</cms:if>
 


 
</div>
</div>

</cms:pages>
<cms:else />

<div id="nav-wrapper_124_2">
<div id="nav-wrapper_124_center">
<a href="../members/login.php?redirect=%2Fmembers%2Fprofile.php" style="font-family:'Open Sans', sans-serif; font-size:12px; font-weight:bold; text-decoration:none; color:#666;">Login</a> |
<a href="<cms:link k_member_registration_template />" target="_blank" style="font-family:'Open Sans', sans-serif; font-size:12px; font-weight:bold; text-decoration:none; color:#666;">Create account</a>
</div>
</div>

</cms:if>
Your code seems to be fine.
Please see if placing the <cms:member_logout_link /> just outside the cms:pages makes any difference.
KK wrote: Your code seems to be fine.
Please see if placing the <cms:member_logout_link /> just outside the cms:pages makes any difference.


Still the same.
The code above is shown on every page as a top navigation bar. The only time that logout link works is when its on the profile edit page :|
Ive also added now to the bottom of the page a logout link. This was done on the index page so the clone for members page and its worked. Long as the link is out of the <cms:page /> tag
Strange.
Can you get me FTP access to your site please?
KK wrote: Strange.
Can you get me FTP access to your site please?


I'll privet message you.
10 posts Page 1 of 1
cron