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: 
I found this code to be working for my application:

```
var auth = new HttpContextWrapper(HttpContext.Current).GetUmbracoAuthTicket();  

if (auth != null)
  { <p>Name: @auth.Name</p>
    <p>ID: @auth.UserData</p>
  }

```

Resource :  ["Umbraco.Web.UmbracoContext.Current.Security.CurrentUser" returns "null" for front-end requests](http://issues.umbraco.org/issue/U4-6496)
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>
}

```