Monday 3 November 2014

Project Session Class to Manage Session in the Project

This Class is used to manage sessions in the system.

public class ProjectSession
    {
        public static long UserID
        {
            get
            {
                if ((HttpContext.Current.Session["UserID"]) == null)
                    return 0;
                else
                    return (long)HttpContext.Current.Session["UserID"];
            }
            set { HttpContext.Current.Session["UserID"] = value; }
        }
        public static string UserName
        {
            get
            {
                if ((HttpContext.Current.Session["UserName"]) == null)
                    return "";
                else
                    return (string)HttpContext.Current.Session["UserName"];
            }
            set { HttpContext.Current.Session["UserName"] = value; }
        }
        public static string LoginId
        {
            get
            {
                if ((HttpContext.Current.Session["LoginId"]) == null)
                    return "";
                else
                    return (string)HttpContext.Current.Session["LoginId"];
            }
            set { HttpContext.Current.Session["LoginId"] = value; }
        }
        public static long RoleID
        {
            get
            {
                if ((HttpContext.Current.Session["RoleID"]) == null)
                    return 0;
                else
                    return (long)HttpContext.Current.Session["RoleID"];
            }
            set { HttpContext.Current.Session["RoleID"] = value; }
        }
}
 

No comments:

Post a Comment