Danish Habib

Danish Habib

  • NA
  • 694
  • 243.5k

How to use veriables across the application

Jan 18 2015 12:32 PM
dear i have a web application in which i have a users they contain different information about themselves like(name,email,Type,id) etc 
Now I am using my login page and getting the values from the user table by passing the specific id of the user like below code
 Try
            cnnUser = New SqlConnection(AppSettings("DbSqlPortal"))
            cmdUser = New SqlCommand("spAdminIsUserValidForLogin", cnnUser)

            cmdUser.CommandType = CommandType.StoredProcedure
            cmdUser.Parameters.Add("@UserName", SqlDbType.VarChar).Value = txtEmail.Text.Trim()
            cmdUser.Parameters.Add("@Password", SqlDbType.VarChar).Value = txtPassword.Text.Trim()
            ' cmdUser.Parameters.Add("@Password", SqlDbType.VarChar).Value = Convert.ToBase64String(hasedBytes)

            cnnUser.Open()
            drUser = cmdUser.ExecuteReader()

            If drUser.Read() Then
                
                'AndAlso (CBool(drUser("IsActive")) And CBool(drUser("IsAdmin"))) Then

                Session("LoggedInIsActive") = drUser("IsActive")
                Session("LoggedInIsAdmin") = drUser("IsAdmin")
                Session("LoggedInUserId") = drUser("UserId")
                Session("UserTypes") = drUser("UserTypes")
                LoggedInUserId = CInt(drUser("UserId"))
                Session("DistrictId") = CInt(drUser("DistrictId"))
                Session("LoggedInUserName") = drUser("Email")
                Session("LoggedInUserFullName") = drUser("FullName")






I am fetching the values and saving them into the session variable because on later stages in my other pages i have to get the email address of logged in user and its type , my application is too much slow, and i think the session variable are not the right place to use please response me 

Answers (1)