Store an hashtable as a session variable

Store an hashtable as a session variable

  
Hello,

I would like to load the contents of a small configuration table into an hashtable that would be placed as a session variable so I could access these configuration settings from any action at any time.

This way I could avoid making many select statements in order to get the configuration whenever I needed some value.

However, it is not possible to set a session variable as an object.

What is the best way to solve this problem?

I thought of converting the hashtable to a record list and then store it in session variable but this doesn't seem right...
Hi Fernando,


In fact you cannot have Session Variables of data type Object. This is so because Session Variables must be serializable and the Object data type is not always serializable.

Your second option is in fact the way the solve the problem. Just create a Structure with two Attributes - Key, Value - and create a Session Variable of data type Record List and Record definition of that Structure you created previously.

Then you can encapsulate the accesses by Key to your Session Variable by creating Actions with the Function property set to Yes and use them in any expression.

The attached sample should do what you want.


Hope this helps,

Rodrigo Castelo