private void addToSession() { foreach (var item in figuresCount) { SessionExtensions.SetInt32(session, item.Key.ToString(), item.Value ?? 0); } SessionExtensions.SetString(session, "last", last); SessionExtensions.SetString(session, "lastChose", lastChoese); //SessionExtensions.SetString(session, "choseIndexs", choseIndexs); }
public bool AuthenticateUser(string userName, string password) { UserMasterModel objUserMaster = _context.TblUserMaster.Where(a => a.UserName == userName && a.Password == password).FirstOrDefault(); if (objUserMaster != null) { SessionExtensions.SetString(_httpContextAccessor.HttpContext.Session, Constants.SessionUserSessions, JsonConvert.SerializeObject(objUserMaster)); SessionExtensions.SetString(_httpContextAccessor.HttpContext.Session, Constants.SessionUserId, Convert.ToString(objUserMaster.Id)); return(true); } else { return(false); } }
public string GetCartId() { ISession current = HttpContext.Session; if (current.Id == null) { if (!string.IsNullOrWhiteSpace(HttpContext.User.Identity.Name)) { SessionExtensions.SetString(current, ShoppingCartActions.CartSessionKey, HttpContext.User.Identity.Name); } else { // Generate a new random GUID using System.Guid class. Guid tempCartId = Guid.NewGuid(); SessionExtensions.SetString(current, ShoppingCartActions.CartSessionKey, tempCartId.ToString()); } } return(current.Id); }
public static string GetCartId(ISession sesh, string userId) { Debug.WriteLine("your id " + userId); //ISession current = Current.Session; if (sesh.Id != userId) { if (!string.IsNullOrWhiteSpace(userId /*current.User.Identity.Name*/)) { SessionExtensions.SetString(sesh, ShoppingCart.CartSessionKey, userId /*current.User.Identity.Name*/); } else { Guid tempCartId = Guid.NewGuid(); SessionExtensions.SetString(sesh, ShoppingCart.CartSessionKey, tempCartId.ToString()); } } Debug.WriteLine("sesh id " + sesh.Id); return(userId); }