Changes
Title
unchanged
How to create a simple logout link in the view?
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
Logout, Link, user, URL, views
Content
changed
[...]
}
```
### Show Logout only to logged-in users
------------------
Just wrap an if arround your code
and ask if the user is not a guest:[...]
```
### What Does Not Work
-
```php
<a href="<?php echo Yii::app()->request->baseUrl; ?>/site/logout">Logout</a>
```
-
```php
<a href="Yii::app()->user->logout();echo Yii::app()->homeUrl; ">Logout</a>
```