Session Variable Member?
-
06-09-2019 - |
Question
I'm using a compiled .dll provided by someone else -- I know little about it, other than it has a session variable that I must access in a way that is strange to me. Not sure what to call it -- have googled for words that I thought might be right, but so far no success. Here is what it looks like:
Session("receipt").username
It's the .username part that I don't understand. What is it? How is it created?
Thanks for any help.
Solution
Session is probably a global object which has a default property which returns a SessionItem object. The SessionItem object is loaded from the browser-session (probably) by the Session object. The SessionItem object has a property username, which is a value stored somewhere in the browser-session.
Some code to clear things up:
Public Class Session
Private Items As SessionItemCollection
Default Public ReadOnly Property SessionItem(ByVal id As String) As Object
Get
Return Me.Items.Find(id)
End Get
End Property
End Class
And you calling the code (Which searches for the "receipt" item in the SessionItemCollection Items from Session):
Session("receipt")
OTHER TIPS
My first guess (since there isn't much other code to go off of) is that the object being stored in the session variable and accessed via Session("receipt")
is of a class that contains a property or member called username
which you are accessing in that fashion.
The basic idea is that Session("receipt")
will pull back whatever this object is (for the sake of instruction we will say it is a receipt object) and the .username
is referencing the username property of that receipt object.