string strConnection = ConfigurationSettings.AppSettings["dns"];
SqlConnection cn = new SqlConnection(strConnection);
cn.Open();
string strsql = "select name,pwd from user where name='" + name + "' or pwd='" + pwd + "'";
SqlCommand cmd = new SqlCommand(strsql, cn);
SqlDataReader rd = cmd.ExecuteReader();
if (rd.Read())
{
if (rd.GetValue(0).ToString() == name)
{
if (rd.GetValue(1).ToString() == pwd)
{
Session["LoginUser"] = rd.GetValue(0);
Response.Redirect("admincp.aspx");
}
else
{
Response.Write("<script>alert('密码错误!')</script>");
}
}
else
{
Response.Write("<script>alert('用户名错误!')</script>");
}
}
else
{
Response.Write("<script>alert('用户不存在!')</script>");
}我通过上面的一段代码实现了登录的登入功能,但现在的情况是,即便我是在登录后的页面进行了操作,处于活动状态,当我登录有一段时间后,就会自动退出登录,需要重新登录了,我想实现,就是我不点 退出 ,就一直不退出,只有点退出了,才会退出,其他即便关闭了IE,下次访问,还是不需要登录,请问这个该怎么做呢?谢谢
SqlConnection cn = new SqlConnection(strConnection);
cn.Open();
string strsql = "select name,pwd from user where name='" + name + "' or pwd='" + pwd + "'";
SqlCommand cmd = new SqlCommand(strsql, cn);
SqlDataReader rd = cmd.ExecuteReader();
if (rd.Read())
{
if (rd.GetValue(0).ToString() == name)
{
if (rd.GetValue(1).ToString() == pwd)
{
Session["LoginUser"] = rd.GetValue(0);
Response.Redirect("admincp.aspx");
}
else
{
Response.Write("<script>alert('密码错误!')</script>");
}
}
else
{
Response.Write("<script>alert('用户名错误!')</script>");
}
}
else
{
Response.Write("<script>alert('用户不存在!')</script>");
}我通过上面的一段代码实现了登录的登入功能,但现在的情况是,即便我是在登录后的页面进行了操作,处于活动状态,当我登录有一段时间后,就会自动退出登录,需要重新登录了,我想实现,就是我不点 退出 ,就一直不退出,只有点退出了,才会退出,其他即便关闭了IE,下次访问,还是不需要登录,请问这个该怎么做呢?谢谢
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="18000"/>