MVC Session Manager Custom Class
MVC Create Session Manager Custom Class c#
public class SessionManager { protected HttpSessionState session; public SessionManager(HttpSessionState httpSessionState) { session = httpSessionState; } public SessionManager() { session = HttpContext.Current.Session; if (this.User_Name == string.Empty) this.IsNull = true; } public void Dispose() { session.Clear(); session.Abandon(); this.IsNull = true; } public bool IsNull { get { return Convert.ToBoolean(session["_IsNull"]); } private set { session["_IsNull"] = value; } } public int System_Id { get { return Convert.ToInt32(session["_System_Id"]); } private set { session["_System_Id"] = value; } } public int User_Id { get { return Convert.ToInt32(session["_User_Id"]); } private set { session["_User_Id"] = value; } } public string User_Name { get { return Convert.ToString(session["_User_Name"]); } private set { session["_User_Name"] = value; } } #region Set Session public void SetSession(int id, int systemId, string memberId, string userName, string gender) { this.User_Id = id; this.System_Id = systemId; this.User_Name = userName; this.IsNull = false; } #endregion Set Session }
MVC Session Manager Custom Class
Reviewed by Bhaumik Patel
on
8:05 PM
Rating: