How to create a simple logout link in the view?

Comparing #3 with #4

Revision #4 was created by mi.sarah mi.sarah on Mar 17, 2014, 10:58:47 AM.

deleted what doesnt work section

Content

[...]
}
```



### 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>
 
```