如何在userid中使用會話... 即我有一個用戶表,其中有列用戶標識符,也離開表,並且在此表中還有一個用戶標識符來顯示哪個用戶標識申請休假 當員工申請休假,然後他/她的用戶ID也保存在休假表... user表中有這碼員工在asp.net中使用會話
protected void Btn_Login_Click(object sender, EventArgs e)
{
try
{
int users = aa.SignIn(txt_username.Value, txt_pass.Value);
if (users == 1)
{
//Session["UserID"] = aa.SignIn(txt_username.Value, txt_pass.Value);
Session["UserID"] = txt_username.Value;
Session["UserTypeID"] = users;
Response.Redirect("AdminOp.aspx");
}
else if (users == 2)
{
//Session["UserID"] = aa.SignIn(txt_username.Value, txt_pass.Value);
Session["UserID"] = txt_username.Value;
Session["UserTypeID"] = users;
Response.Redirect("leave.aspx");
}
}
catch
{
Label8.Text= "Incorrect User Name or Password";
}
的所有信息我保存會話用戶名
這段代碼有什麼問題?你到底想要什麼? –
這是所有用戶類型的登錄代碼,我想在會話中保存用戶標識 –
會話不是設置適當身份驗證系統的最佳方式。您應該檢查[ASP.NET身份驗證](http://msdn.microsoft.com/en-US/library/eeyk640h(v = vs.100).aspx)以獲得更可靠的其他解決方案。 – CharlesAD