I want to pass Userid with Email in Cookie but it always 0.
if (user.IsValid(user.Email, user.Password)) { FormsAuthentication.SetAuthCookie(user.Email + "|" + user.Id, true); return RedirectToAction("Index", "TestValidUser"); }
public bool IsValid(string email, string password) { bool IsValid = false; var user = db.GistlerUsers.FirstOrDefault(u => u.Email == email); if (user != null) { if (user.Password == EncryptPassword(password)) { IsValid = true; } } return IsValid; }
user.Email has value but user.Id =0 always.