I'm developing a blog in MVC, I need to know if the admin
is logged, and if is logged then show him links for delete, edit
, and create
posts, for the other users they don't need to see those links, I was thinking in use a boolean
Session
variable for this, the value of the variable is true
if admin
is logged, otherwise false
, I have read that we should avoid to use Session
variables. Do you think is a good practice to do this using Session
variable?
I know that using [Authorize(Users ="admin@email.com")]
I can give or deny access to actions depending on which user is logged.
But how could I know IF the admin is logged using a condition?
For example: if(someCode.GiveMeUserNameLogged == "admin@email.com" ){//do other code}
???