如何处理不同用户的会话超时[重定向] [英] How to handle session timeout [redirect] with different users

查看:86
本文介绍了如何处理不同用户的会话超时[重定向]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



我的网站上有3个用户,每个用户在退出时都会重定向到不同的页面。



如何在会话超时时处理这个问题???



示例:



工厂用户:

*在会话中存储凭据[FactoryInfo];

*重定向到login.aspx



管理员用户:

*在会话中存储其凭据[AdminUser];

*重定向到adminlogin.aspx



正常用户:

*在会话[NormalUser]中存储其凭据;

*重定向到homelogin.aspx



如果用户按下注销链接,则会根据其会话变量将每个用户重定向到其登录页面。



  if (会话[  FactoryInfo ]!=  null  //  工厂用户 
{
Session.Clear();
Response.Redirect( login.aspx);
}
else if (会话[ AdminUser]!= null // 管理员用户
{
Session.Clear();
Response.Redirect( adminlogin.aspx);
}
else if (会话[ NormalUser]!= null // 普通用户
{
Session.Clear();
Response.Redirect( homelogin.aspx);
}





现在如果会话超时,那么所有会话变量都是NULL !!

所以如何检测当前用户并重定向到其特定的登录页面?!!!

解决方案

< blockquote> ...我有一个临时解决方案。在主页面上保留隐藏的字段或标签..并在您登录时打印usertype。并且你会找到解决方案。



每当会话超时..检查标签文本并找到usertype

..并重定向到理想的页面。注销时。


Dear All,

I have 3 users on my site and each one of them when sign out it redirects to a different page.

how can i handle this when session time out???

Example:

Factory User:
* Stores credentials in session["FactoryInfo"];
* redirects to login.aspx

Admin User:
* Stores its credentials in session["AdminUser"];
* redirects to adminlogin.aspx

Normal User:
* Stores its credentials in session["NormalUser"];
* redirects to homelogin.aspx

No if user presses on logout link it redirects each user to its login page based on its session variable.

if (Session["FactoryInfo"] != null)//Factory User
{
    Session.Clear();
    Response.Redirect("login.aspx");
}
else if (Session["AdminUser"] != null)//Admin User
{                
    Session.Clear();
    Response.Redirect("adminlogin.aspx");
}
else if(Session["NormalUser"] != null)//Normal User
{
    Session.Clear();
    Response.Redirect("homelogin.aspx");
}



Now if the session times out, then all session variables are NULL!!
so how can i detect the current user and redirects to its specific login page?!!!

解决方案

... i have a temporary solution . keep a hidden field or label on the master page .. and print the usertype when u logged in . and u will find the solution .

whenever session will timed out .. check the label text and find the usertype
.. and redirect to the desirable page . when logout .


这篇关于如何处理不同用户的会话超时[重定向]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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