更新时间:2023-11-13 21:36:40
在登录时,当用户通过身份验证时:
At login, when user is authenticated:
Session["IsLoggedIn"] = "Yes";
//OR
Session["LoggedInUserId"] = "User621";
注销时,清除会话:
At the time of logout, clear the session:
Session.Clear();
//OR
Session["IsLoggedIn"] = null;
如果要检查用户是否登录,只需查看会话值是否存在.如果它为null,则为空.
If you want to check if user is logged in or not, just see if session value exists. If it''s null then not.