我有多个会话变量,它们都不接受其他变量赋予它们的任何值。我试图调试,什么都没发现。这是我正在使用的功能......
public void logIn(object sender, EventArgs e) //triggers when login button is clicked
{
db_connection(); //connects to database using above function
string emailAddress = email.Text.ToString();
string passwordR = password.Text.ToString(); //email and password are converted to variables
DataTable table = new DataTable();
MySqlCommand select = new MySqlCommand("SELECT personID, address_addressID from person WHERE email='" + emailAddress + "' and password = '" + passwordR + "'", connect); //brings back the person ID if user details are correct
using (MySqlDataAdapter adapter = new MySqlDataAdapter(select))
{
adapter.Fill(table);
string sessionVar = table.Rows[0]["personID"].ToString();
Session["personID"] ="";
Session["personID"] = sessionVar;
int sessionVarAddress = Int32.Parse(table.Rows[0]["address_addressID"].ToString());
Session["address_addressId"] = sessionVarAddress;
if (table.Rows.Count != 0)
{
if (Session["personID"] != null) //if the person ID is present do this following statement
{
hideDiv.Visible = false;
}
Response.Redirect("myAccount.aspx"); // if user logs in successfully redirect to my account pag
}
else
{
Response.Redirect("index.aspx"); //if login fails, home page is returned
}
connect.Close();
}
}