views:

81

answers:

2

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.

+2  A: 

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")
Ropstah
Thank you -- that had been driving me crazy. "Session Item Object" After you named it, I was able to google it, and found a great explanation on codeproject for how to use it: http://www.codeproject.com/KB/session/SessionDiagram.aspx?display=Print. Thanks again.
dave
You're welcome :)
Ropstah
Oh, and you are allowed to mark my answer as your answer if you like hehe
Ropstah
+1 cos I hate seeing accepted answers with no marks :)
Patrick McDonald
A: 

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.

TheTXI