private static User currentUser = null;
高效的Session读写.        
/// <summary>
高效的Session读写.        
/// 当前用户
高效的Session读写.        
/// </summary>

高效的Session读写.        public static User CurrentUser{
高效的Session读写.            
get{
高效的Session读写.                
if(currentUser != null && HttpContext.Current.Session["LoginUser"!= null)
高效的Session读写.                    
return currentUser;
高效的Session读写.                
高效的Session读写.                
if(HttpContext.Current.Session["LoginUser"!= null){
高效的Session读写.                    currentUser 
= (User)HttpContext.Current.Session["LoginUser"];
高效的Session读写.                    
return currentUser;
高效的Session读写.                }

高效的Session读写.
高效的Session读写.                
if(currentUser != null && HttpContext.Current.Session["LoginUser"== null){
高效的Session读写.                    
return currentUser;
高效的Session读写.                }

高效的Session读写.                
//没有登陆的用户,自动读取cookie登陆
高效的Session读写.
                currentUser = new PopForum.Common.Entity.User();
高效的Session读写.                HttpCookie c 
= HttpContext.Current.Request.Cookies["UserInfo"];
高效的Session读写.                
if(c!=null && c.Value!=""){
高效的Session读写.                    FormsAuthenticationTicket ticket 
= FormsAuthentication.Decrypt(c.Value);
高效的Session读写.                    Common.DataMapping.UserInfo info 
= null;
高效的Session读写.                    Users users 
= new Users();
高效的Session读写.                    
int r = users.CheckUser(ticket.Name,out info);
高效的Session读写.                    
if(r==1){
高效的Session读写.                        currentUser.UserId 
= info.UserId;
高效的Session读写.                        currentUser.UserName 
= info.UserName;
高效的Session读写.                        currentUser.Status 
= (Common.UserStatus)info.UserStatus;
高效的Session读写.                        currentUser.Point 
= info.Point;
高效的Session读写.                        DataTable table 
= DataBase.ExecuteSQLTable("select rr.rightid from t_roleright rr,t_userrole ur where rr.roleid=ur.roleid and ur.userid="+currentUser.UserId.ToString());
高效的Session读写.                        
foreach(DataRow row in table.Rows){
高效的Session读写.                            currentUser.Rights.Add((Common.Right)row[
"rightid"]);
高效的Session读写.                        }

高效的Session读写.                        
//判断用户是否有系统管理权限
高效的Session读写.
                        if(currentUser.HaveRight(Common.Right.SiteAdmin)){
高效的Session读写.                            
//更新用户登陆信息
高效的Session读写.
                            users.LoginUpdate(ref info,currentUser);
高效的Session读写.                            currentUser.Point 
= info.Point;
高效的Session读写.                            Sessioner.Add(
"LoginUser",currentUser);
高效的Session读写.                        }

高效的Session读写.                            
//判断网站是否关闭,但管理员可以登陆
高效的Session读写.
                        else if(Common.Configs.ForumConfig.SiteConfiger.CloseFlag){
高效的Session读写.                            
throw new CtyException("网站被关闭,暂时无法访问",DealType.RediretErrorPage);
高效的Session读写.                        }

高效的Session读写.
//                            //判断是否允许登陆
高效的Session读写.
//                        else if(!Common.Configs.ForumConfig.SiteConfiger.LoginFlag){
高效的Session读写.
//                            throw new CtyException("登陆被禁止,暂时无法登陆",DealType.RediretErrorPage);
高效的Session读写.
//                        }
高效的Session读写.
                        else{
高效的Session读写.                            users.LoginUpdate(
ref info,currentUser);
高效的Session读写.                            currentUser.Point 
= info.Point;
高效的Session读写.                            Sessioner.Add(
"LoginUser",currentUser);
高效的Session读写.                        }

高效的Session读写.                    }

高效的Session读写.                }
else{
高效的Session读写.                    
//匿名用户
高效的Session读写.
                    if(!Common.Configs.ForumConfig.SiteConfiger.AnonymousFlag)
高效的Session读写.                        
throw new CtyException("网站不允许匿名用户访问",DealType.RediretErrorPage);
高效的Session读写.                }

高效的Session读写.                
return currentUser;
高效的Session读写.            }
set{
高效的Session读写.                 Sessioner.Add(
"LoginUser",value);
高效的Session读写.                 currentUser 
= value;
高效的Session读写.             }

高效的Session读写.        }