Answers.Body: <p>Might be going overboard, but you could have a plugin with it's own controller that provided different logout behavior.</p>
  
  <p>But it sounds like to me what you're looking for is something like a 'logoutRedirect' config setting.  Probably worth adding to the <a href="http://feedback.buildwithcraft.com" rel="nofollow">feedback site</a>!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-29T23:20:07.700Z
Answers.Text: Thanks! Right, but the confusion comes from -- please correct me if I'm wrong -- that `loginUrl` actually goes to the specified login page, and stays there, if the user isn't logged in. While `logoutUrl` logs out, but just goes to the homepage. One would expect these 2 similar variables to act more identical. At least, to me. But it's no biggie. I'll post it on the feedback site, but don't expect much animo for this niche thing. Maybe it's just me.
Answers.UserDisplayName: tom
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-05-23T09:26:45.710Z
Answers.Text: As of today, I can't find the note about being redirected to the homepage afterwards. Is that still the case? This seems really odd... there's no way after a user logs out to provide some kind of feedback to them? Just a redirect to the homepage?
Answers.UserDisplayName: Mike
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-29T17:41:02.263Z
Answers.LastActivityDate: 2015-05-29T17:41:02.263Z
Answers.UserDisplayName: Brad Bell
Answers.Body: <p>I use a little hack using the <a href="https://github.com/nystudio107/retour" rel="nofollow noreferrer">retour</a> plugin to redirect request to login page.
  It's no longer maintained but it's fully working on Craft CMS 2.x versions.</p>
  <p>You need to install this plugin and set new redirect:</p>
  <p><strong>Legacy URL Pattern:</strong> <code>yourHackyLogoutUrl</code></p>
  <p><strong>Destination URL:</strong> <code>youFrontEndLoginUrl</code></p>
  <p>Than you need to add a new route in <em>Settings -&gt; Routes</em></p>
  <p><strong>If the URI looks like this:</strong> <code>yourHackyLogoutUrl</code></p>
  <p><strong>Load this template:</strong> <em>hacky_logout_template</em></p>
  <p>In your <em>hacky_logout_template</em> add this:</p>
  <pre><code>{% do craft.cookies.set( &quot;CSRF&quot; ) %}
  {% do craft.cookies.set( &quot;PHPSESSID&quot; ) %}
  {% exit 404 %}
  </code></pre>
  <p>By visiting <code>yourHackyLogoutUrl</code> Craft CMS picks the template and reset/remove/end user session. If we wouldn't remove it than we would still be logged in.
  Be careful. The <code>PHPSESSID</code> cookie name is my custom name for php session cookie. You may have it called differently.</p>
  <p>Also to call <code>{% do craft.cookies.set( &quot;PHPSESSID&quot; ) %}</code> you must have a cookie plugin installed. I use <a href="https://github.com/nystudio107/cookies/blob/master/README.md" rel="nofollow noreferrer">the cookies plugin by nystudio107</a>. But this is optional as you can reset cookies by javascript.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-03T14:26:53.633Z
Answers.LastActivityDate: 2020-07-03T14:26:53.633Z
Answers.UserDisplayName: Dominik Krulak
Body: <p>In the general config settings, one can set a <a href="http://buildwithcraft.com/docs/config-settings#logoutPath" rel="nofollow">logoutPath</a>, and one can use it using the <code>logoutUrl</code> Global. </p>
  
  <p>However, it says also in the docs: Note that Craft will automatically redirect users to your homepage after going here; there’s no such thing as a “logout page”.</p>
  
  <p>In short; is there any other way to log a user out, besides "triggering" a visit to the predefined <code>logoutPath</code>, which logs users out, but immediately redirects them to the homepage; as it would be more elegant and userfriendly to show some kind of "you've been logged out" message instead first.</p>
  
Tags: <login>
Title: Logging out users - logoutPath & logoutUrl
ThreadText: # Logging out users - logoutPath & logoutUrl
  
  (Asked by: username_0 on 2015-05-29)
  
  In the general config settings, one can set a [logoutPath](http://buildwithcraft.com/docs/config-settings#logoutPath), and one can use it using the `logoutUrl` Global.
  
  However, it says also in the docs: Note that Craft will automatically redirect users to your homepage after going here; there’s no such thing as a “logout page”.
  
  In short; is there any other way to log a user out, besides "triggering" a visit to the predefined `logoutPath`, which logs users out, but immediately redirects them to the homepage; as it would be more elegant and userfriendly to show some kind of "you've been logged out" message instead first.
  
  **Tags:** login
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-05-29. Score: 2
  
  Might be going overboard, but you could have a plugin with it's own controller that provided different logout behavior.
  
  But it sounds like to me what you're looking for is something like a 'logoutRedirect' config setting. Probably worth adding to the [feedback site](http://feedback.buildwithcraft.com)!
  
  > **Comments:**
  > **username_0**: Thanks! Right, but the confusion comes from -- please correct me if I'm wrong -- that `loginUrl` actually goes to the specified login page, and stays there, if the user isn't logged in. While `logoutUrl` logs out, but just goes to the homepage. One would expect these 2 similar variables to act more identical. At least, to me. But it's no biggie. I'll post it on the feedback site, but don't expect much animo for this niche thing. Maybe it's just me.  
  > **username_2**: As of today, I can't find the note about being redirected to the homepage afterwards. Is that still the case? This seems really odd... there's no way after a user logs out to provide some kind of feedback to them? Just a redirect to the homepage?  
  
  ---
  
  ### Answer by username_3 on 2020-07-03. Score: 2
  
  I use a little hack using the [retour](https://github.com/nystudio107/retour) plugin to redirect request to login page.
  It's no longer maintained but it's fully working on Craft CMS 2.x versions.
  
  You need to install this plugin and set new redirect:
  
  **Legacy URL Pattern:** `yourHackyLogoutUrl`
  
  **Destination URL:** `youFrontEndLoginUrl`
  
  Than you need to add a new route in *Settings -> Routes*
  
  **If the URI looks like this:** `yourHackyLogoutUrl`
  
  **Load this template:** *hacky\_logout\_template*
  
  In your *hacky\_logout\_template* add this:
  
  ```
  {% do craft.cookies.set( "CSRF" ) %}
  {% do craft.cookies.set( "PHPSESSID" ) %}
  {% exit 404 %}
  
  ```
  
  By visiting `yourHackyLogoutUrl` Craft CMS picks the template and reset/remove/end user session. If we wouldn't remove it than we would still be logged in.
  Be careful. The `PHPSESSID` cookie name is my custom name for php session cookie. You may have it called differently.
  
  Also to call `{% do craft.cookies.set( "PHPSESSID" ) %}` you must have a cookie plugin installed. I use [the cookies plugin by nystudio107](https://github.com/nystudio107/cookies/blob/master/README.md). But this is optional as you can reset cookies by javascript.
  
  
  ---
  
  