Store/retrieve object in session

/ Published in: C#
Save to your folder(s)

Copy this code and paste it in your HTML
  1. //On Login page
  2. User currentUser = <get the User entity here, including relations to UserRights>;
  3. Session.Add("CurrentUser", currentUser);
  5. //On another page
  6. User restoredUser = Session["CurrentUser"] as User;
  7. if (restoredUser != null)
  8. {
  9. //use the User entity here to check user's rights
  10. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.