会话超时和登录 [英] Session timeout and login

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

问题描述

如果用户已登录,并在我的网站打开的任何网页,什么也不做20分钟。现在,如果他从菜单中选择任何东西或点击,他将被重定向到登录页面的任何按钮。现在,我登录后有问题。用户被重定向到主网页仅以因为我想用户重定向到那里,他希望当他点击菜单项之前去的页面。

感谢您提前帮助..


解决方案

这是你会被重定向登录后到登录页面非常明显的事情
我向您展示几种方法来实现这一目标...

 会话[将把userid]

现在,当用户处于闲置状态,现在20分钟的purchase.aspx :(
 因此,当他重新加载或点击您的导航任何页面上,将工作像这样

在页面加载使用此code


 如果(会话[将把userid]!= NULL)
           {
//做的东西,因为你会不为空
}
其他
{
会议[previouspage] =页面名称;
的Response.Redirect(login.aspx的);
}

在登录页使用该会话重定向到previous页


现在最好,如果你不想会话加载到内存中的另一种方式实现这一目标的方式是


  

查询字符串


 如果(会话[将把userid]!= NULL)
           {
//做的东西,因为你会不为空
}
其他
{的Response.Redirect(?login.aspx的previousPage =+您的网页名称);
}

在登录页你将有查询字符串previous页

的Request.QueryString [previousPage]在这您previous页将被定义

因此​​,在短期,你将在这个previous页面,您可以重定向到成功登录后页面

我希望这会帮助你:)

If user has logged in and opened any page in my website and does nothing for 20 mins. Now if he selects any thing from menu or clicks any button he is redirected to login page. Now I have problem after login. The user is redirected to main page only where as I want to redirect user to the page where he wanted to go before when he clicked the menu item.

Thanks for help in advance..

解决方案

This is very obvious thing that you are redirected to login page after login I am showing you several ways to achieve this...

session["userid"]

Now when user is idle for 20 mins now at purchase.aspx :( So when he reload or click on any page from your navigation it will work like this

Use this code in a page load


if (Session["userid"] != null)
           {
// do stuff because your session is not null
}
else
{
session["previouspage"]="your page name";
response.redirect("login.aspx");
}

and at login page use this session to redirect to the previous page


Best way now if you don't want to load the session into memory another way to achieve this is

query string

if (Session["userid"] != null)
           {
// do stuff because your session is not null
}
else
{

response.redirect("login.aspx?PreviousPage="+Your page name);
}

and at login page you will have a previous page with query string

request.querystring["PreviousPage"] in this your previous page will be defined

So in short you will have a previous page in this and you can redirect to that page after successful login

I hope this will help you :)

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

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