I am support a legacy application where I see code like this:
'Use Session for everything?
If Session("UserType") = "Admin" Then
'do admin something
ElseIf Session("UserType") = "Manager" Then
'do manager stuff
ElseIf Session("UserType") = "User" Then
'do regular stuff
Else
'do anonymous stuff
End If
Would declaring a local variable, assigning the session variable to the local variable, then using the local variable for tests be faster and better for performance?
'Use local variable?
Dim UT As String = Session("UserType")
If UT = "Admin" Then
'do admin something
ElseIf UT = "Manager" Then
'do manager stuff
ElseIf UT = "User" Then
'do regular stuff
Else
'do anonymous stuff
End If
Or does IIS automatically cache the Session variable value once it retrieves it for the current executing code?