登录页面的会话管理 [英] session managememt for login page
本文介绍了登录页面的会话管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何以登录形式使用会话变量并在成功登录后重定向到另一个页面.
how to use session variables in login form and redirect to another page after successful login.
推荐答案
查看此处:
传统登录页面设计讨论 [
Look here:
Traditional Login page design discussion[^]
当用户成功通过身份验证后,便从用于身份验证的表中获取数据.用户并像这样将数据存储到会话中
C#语法
when the user is authenticate successfully then get the data from the table from which you authenticate the user and store that data into session like this
C# syntax
session["Userid"] = dt.rows[0]["UserName"];
>
在vb中
in vb
Session("UserId") = dt.rows(0)("UserName")
这里的用户名是存储用户数据的数据库表的列.
here user name is the column of the database table in which you store the user data.
是的,如Shabbir建议-
Yeah as Shabbir suggested-
C# syntax
session["Userid"] = dt.rows[0]["UserName"];
Response.Redirect("AnotherPage.aspx");
--AnotherPage.aspx
在此页面的页面加载功能上,使用如果"语句检查会话是否存在,如果不存在用户会话,则以
重定向到登录页面
--AnotherPage.aspx
On this page''s Page load Function check whether the sessions exists or not by using "If" statement,If User Session Doesnot exists then redirect to Login Page as
if(session["Userid"]==null)
{
Response.Redirect("login.aspx");
}
这篇关于登录页面的会话管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文