使用会话登录页面代码 [英] login page code using sessions

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

问题描述

使用会话如何在asp.net中为登录页面编写代码

using session how write code for login page in asp.net

推荐答案

http://msdn.microsoft.com/en-us/library/ms178329.aspx [

会话存储单个用户信息(每人一个会话).

因此您可以将用户名和密码保留在Session对象中,以备将来使用.
会话是服务器端状态管理技术,因此更加安全
Session store single user information (per person a session).

so you can keep username and password in Session object, for further use.
session is serverside state management technique so more secure
Session["Login_User"] = "ABC";
Session["PWD"] = "PWD";


您也可以将命中计数存储在会话中,如果命中计数大于3,则可以通过更新数据库中的某些标志指示器来锁定用户ID.


also u can store hitcount in session veriable, if hitcount is more than 3 then you can lock user id by updating some flag indicator in database.


受保护的无效btnlogin_Click(对象发送者,EventArgs e)
{

SqlDataAdapter da =新的SqlDataAdapter(从strUserregistration中选择*,其中strusername =""+ txtusername.Text +"''和strpassword =" + txtpassword.Text +",(SqlConnection)Application.Get("con ));
DataSet ds = new DataSet();
da.Fill(ds);
如果(ds.Tables [0] .Rows.Count> 0)
{
字符串strname = ds.Tables [0] .Rows [0] [2] .ToString();
字符串strtype = ds.Tables [0] .Rows [0] [13] .ToString();

如果(strtype =="Active")
{
Response.Redirect("userquerysend.aspx");
}
其他
{
lblmessage.Text =联系我们的管理员或等待一段时间以使您的非活动状态";
}
}
其他
{
lblmessage.Text =您输入的用户名或密码不正确.";
}
}
protected void btnlogin_Click(object sender, EventArgs e)
{

SqlDataAdapter da = new SqlDataAdapter("select * from strUserregistration where strusername=''" + txtusername.Text + "'' and strpassword= ''" + txtpassword.Text + "''", (SqlConnection)Application.Get("con"));
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
string strname = ds.Tables[0].Rows[0][2].ToString();
string strtype = ds.Tables[0].Rows[0][13].ToString();

if (strtype == "Active")
{
Response.Redirect("userquerysend.aspx");
}
else
{
lblmessage.Text = "Contact Our ADmin Or Wait for some time Your In Inactive ";
}
}
else
{
lblmessage.Text = "The username or password you entered is incorrect.";
}
}


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

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