<p>I believe you'll want something like this...</p>

<pre><code>{% if currentUser %}
    &lt;a href="{{ url('logout') }}"&gt;Logout&lt;/a&gt;
{% else %}
    &lt;a href="{{ url('login') }}"&gt;Login&lt;/a&gt;
{% endif %}
</code></pre>

CC BY-SA 3.0
2016-05-20T08:18:45.303Z
Thank Lindsey D, your method work perfect ! Much Appreciated
William Spark
CC BY-SA 3.0
2016-05-20T05:34:13.080Z
2016-05-20T05:34:13.080Z
Lindsey D
<p>I am trying to figure out how to check if a visitor is not logged in so that I can show the correct button. E.g</p>

<pre><code>{% if craft.session.isLoggedIn %}
    &lt;a href="{{ logoutUrl }}"&gt;Logout&lt;/a&gt;
{% else %}
    {% craft.session.isGuest %}
    &lt;a href="{{ logoutUrl }}"&gt;Client/a&gt;
{% endif %}
</code></pre>

<p>What is the best method to display a "sign in" button for a visitor that takes them to a login page and then once logged in, show "Logout"?</p>

<templating>
Check if Visitor show logon button
# Check if Visitor show logon button

(Asked by: username_0 on 2016-05-20)

I am trying to figure out how to check if a visitor is not logged in so that I can show the correct button. E.g
{% if craft.session.isLoggedIn %}
    Logout
{% else %}
    {% craft.session.isGuest %}
    Client/a>
{% endif %}

What is the best method to display a "sign in" button for a visitor that takes them to a login page and then once logged in, show "Logout"?

**Tags:** templating

---

## 1 answers

### Answer by username_1 on 2016-05-20. Score: 4 | Accepted answer

I believe you'll want something like this...
{% if currentUser %}
    Logout
{% else %}
    Login
{% endif %}

> **Comments:**
> **username_0**: Thank Lindsey D, your method work perfect ! Much Appreciated  

---

