Question: How can i check if user is logged in to umbraco from the view(.cshtml)? 

I would also know how to check the users role. 

`User.Identity.IsAuthenticated` always returns false.

```
if( User has role = "someRole" )  
{  
    do stuff
}

```

Im using Umbraco version: 7.8.1

Answer: 
If `User.Identity.IsAuthenticated` is false you are probably not calling `FormsAuthentication.SetAuthCookie(username, true);` after the user is successfully validated.

To check the authentication and roles use:

```
var userIsAuthenticated = Request.IsAuthenticated;
var userIsAdmin = User.IsInRole(role: "admin");

```
To check if an Umbraco user is logged in on front-end, I'm using this:

```
var isLoggedInUmbraco = userTicket.GetUmbracoAuthTicket()!=null;
//To add a Umbraco edit link on a page:
if(isLoggedInUmbraco){
<a href="/umbraco/#/content/content/edit/@Model.Content.Id">Edit Page</a>
}

```