protected void SetCurrentAccountVariables(MembershipUser user) { DictionaryModel.DictionaryEntities entities = new DictionaryModel.DictionaryEntities(); // >>>>>IZVYN METODA Guid aspnetId = (Guid)user.ProviderUserKey; DictionaryModel.Account account = entities.Accounts.FirstOrDefault(acc => acc.ASPNETID == aspnetId); if (account != null) //The Manager is Admin { this.CurrentAccountUsername = user.UserName; this.CurrentAccountId = account.Id; this.CurrentUserNames = account.FirstName + " " + account.LastName; } else //The user is guest { this.CurrentAccountUsername = "******";//.CurrentManagerUsername = user.UserName; this.CurrentAccountId = 1; //.CurrentCompanyId = accountManager.CompanyId.Value;// accountManager.CompanyId; } HttpCookie UserName = new HttpCookie("UserName", user.UserName); Response.Cookies.Add(UserName); }