Trouble with session property

I would like to store some information in a property I added to a session so I can use it on different web pages the user might access. The property is the primary key for the facility the user chose when he logged in. I wrote this which executes without error,

session.FacKey = rs.Field("FacKey").StringValue

but the debugger reveals that there is nothing in the session.FacKey property. Trying to use the property in an SQL statement also fails with no value returned for session.FacKey. FacKey was created in the IDE as a public string property of the session (string because its primary use will be in SQL statements). My database is also a property of the session and works as expected.

Maybe you could provide more details:

  • where is your code executed, session event ? (remember, using session within the session object context is bad practice and you should use self.FacKey)
  • did you debug this line and what’s the rs like ?
  • how/where do you open your SQL db and how/where do you get the recordset ?

The code is executed in the login window using the recordset returned after the user enters a valid email address and password. The correct facility value is returned in the recordset. The CubeSQL database connection is made in the session.Open. There is also a database connection made in the app.Open for HandleSpecialURL events.

I have been passing values from page to page and thought using a session property would be more efficient, but I haven’t been able to get it to work.

Apparently, this problem is caused by multiple sessions being active in my browser. I just put a breakpoint in a routine that works with session.FacKey in the SQL statement. I have a CurrentSessions= session statement in the event and when I look at it in the debugger at the breakpoint, it shows nothing for the FacKey value while the statement variable shows the value as it should. I have seen breakpoints set in and session.shown fire multiple times when I only expected it once. Never worried about it before as the program worked, Now I need to look into what is happening more.