Link to home
Start Free TrialLog in
Avatar of Stacey Fontenot
Stacey Fontenot

asked on

Hide Menu Item in Layout

I have an MVC C# Web application. I need a way to check a cookie name ="User_Role", if it = "UR500" then hide a menu object which is included in the layout.cshtml. Where would I place this script?
ASKER CERTIFIED SOLUTION
Avatar of Zakaria Acharki
Zakaria Acharki
Flag of Morocco image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

I don't recommend to use JS for this, this is not secure.
You should use PHP or server side code to check the role and display / hide the menu item like you would do in your page for the content.
if user_role = something show else hide ....
Avatar of Stacey Fontenot
Stacey Fontenot

ASKER

is your syntax correct? I'm getting an token error with poor format.
Could you please take a screenshot and show us the error message?
Great work.
Glad I could help.