Session["用户状态"]="合法";
其他界面
try
{
if (Session["用户状态"].ToString()!="合法")
{
Response.Redirect("WebForm2.aspx");
}
}
catch
{
Response.Redirect("WebForm2.aspx");
}
SESSION的有效期
Session.Timeout=10;//有效期为10分钟
当用户离开时可以用Session.Abandon();来结束会话。这样比较安全。