创建用于登录和注销的会话 [英] session creation for login and logout

查看:77
本文介绍了创建用于登录和注销的会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于创建用于登录和注销的会话的代码是什么???/

what is code for the creation of session for login and logout ??/

推荐答案

在登录时,当用户通过身份验证时:
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.


这篇关于创建用于登录和注销的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆