且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用会话登录页面代码

更新时间:2023-12-01 15:48:34

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.";
}
}