title: Forms Authentication - Accessing User Data
body: <p>I’m having some difficulty understanding how to access specific user data while using Forms Authentication.</p>
  
  <p>I have already set up Forms Authentication for a User and an Admin.</p>
  
  <p>When a User tries to log in, here is the code that runs:</p>
  
  <pre><code>    protected void buttonLogIn_Click(object sender, EventArgs e)
      {
          string email = TextBoxEmail.Text.Trim();
          string password = TextBoxPassword.Text.Trim();
          UserType userType = UserType.User; //temporary value
          string firstName = string.Empty;
          string lastName = string.Empty;
          bool success = DBAppLayer.AuthenticateLogIn(email, password, out userType, out firstName, out lastName);
          if (success == true)
          {
              Session.Add("email", email);
              Session.Add("firstname", firstName);
              Session.Add("lastname", lastName);
  
              switch (userType)
              {
                  case DBDataLayer.UserType.User:
                      FormsAuthenticationUtil.SetAuthCookie(email, "User,", false);
                      Response.Redirect("~/User/UserDashboard.aspx", false);
                      break;
                  case DBDataLayer.UserType.Admin:
                      FormsAuthenticationUtil.SetAuthCookie(email, "Admin", false);
                      Response.Redirect("~/AdminArea/AdminDashboard.aspx", false);
                      break;
              }
          }
          else
          {
               labelError.Text = "Bad username/password.";
          }
      }
  </code></pre>
  
  <p>This successfully redirects a User to their dashboard. Now when the User is in /User/UserDashboard.aspx, I want to display the User’s profile information that is stored in the database, such as the User’s job and age.</p>
  
  <p>The problem is, I’m not sure how to access this specific User’s data in UserDashboard.cs. Do I need to create an Authentication Ticket? If so, would I do this in the login page?</p>
  
  <p>Any links or suggestions would be appreciated.</p>