string key = TextBox1.Text; //用户名文本框设为cache关键字
string uer = Convert.ToString(Cache[key]); //读取cache中用户相应的值
//判断cache中是否有用户的信息,如果没有相关的值,说明用户未登陆
if (uer == null || uer == String.Empty)
{
//定义cache过期时间
TimeSpan SessTimeout = new TimeSpan(0, 0, System.Web.HttpContext.Current.Session.Timeout, 0, 0);
//第一次登陆的时候插入一个用户相关的cache值,
HttpContext.Current.Cache.Insert(key, key, null, DateTime.MaxValue, SessTimeout, System.Web.Caching.CacheItemPriority.NotRemovable, null);
Session["ADMINID"] = TextBox1.Text;
Response.Redirect("main.ASPx");
}
else
{
//重复登陆
Response.Write(""); 这是从网上找到的代码,过期时间设为session.timeout.当用户关闭浏览器时,这个cache项会不会被删?
用membershipuser.isueronline判断用户是否在线,登入,不是更简单吗?
请高手能详细解说一下}
string uer = Convert.ToString(Cache[key]); //读取cache中用户相应的值
//判断cache中是否有用户的信息,如果没有相关的值,说明用户未登陆
if (uer == null || uer == String.Empty)
{
//定义cache过期时间
TimeSpan SessTimeout = new TimeSpan(0, 0, System.Web.HttpContext.Current.Session.Timeout, 0, 0);
//第一次登陆的时候插入一个用户相关的cache值,
HttpContext.Current.Cache.Insert(key, key, null, DateTime.MaxValue, SessTimeout, System.Web.Caching.CacheItemPriority.NotRemovable, null);
Session["ADMINID"] = TextBox1.Text;
Response.Redirect("main.ASPx");
}
else
{
//重复登陆
Response.Write(""); 这是从网上找到的代码,过期时间设为session.timeout.当用户关闭浏览器时,这个cache项会不会被删?
用membershipuser.isueronline判断用户是否在线,登入,不是更简单吗?
请高手能详细解说一下}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货