I am currently using the [Authorise] attribute in Controllers to restrict Views to be only visible if the website user is logged in.
But how do you restrict only part of a view? eg. Something like this...?
<% if(SomeoneIsLoggedIn) { %>
<div id="protectedContent">...</div>
<% } %>
This method is called when a login is successful:
public static void CreateLoginCookie(User u)
{
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(u.Id.ToString(), true, 9*60);
string encryptedTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket) { Expires = DateTime.Now.AddHours(9) };
HttpContext.Current.Response.Cookies.Add(cookie);
}
(that 9 hours doesn't seem to work btw, the code might be flawed but it's working - it lets people login)
Thanks in advance.