Sessions can store objects?

Hi,

There is a way of storing objects in TROSession (Delphi) using In-Memory Session Manager?

API class (http://wiki.remobjects.com/wiki/TROSession_Class) shows that I can save variants data but not references to TObjects … Or I can hold references to objects in variants, like this (not tested):

obj := TObject.Create;
v := NativeUInt(obj);
obj := TSomeObject(NativeUInt(v));

source: http://stackoverflow.com/questions/366329/why-cant-delphi-variants-hold-objects

Is this safe? Or is there a better way to do this? Maybe using: Event-Driven Session Manager … but event parameters expects TROSession types.

Thanks
Willian.

The Session Manager components have an OnCustomCreateSession event. Here you can return your own TROSession descendant. Your custom session object can have whatever properties you like to store extra information.

However, beware that, if you use this method, it’s not compatible with the Olympia session manager.

If you’d like to both use your own custom TROSession descendant and be compatible with Olympia, I’d recommend overriding LoadFromStream and SaveToStream to serialize your custom data within the Values[] property;

Thanks nwoolls, I’m dealing with it only now and your hint was very usefull.

I was looking for a practical example and I found this:

http://wiki.remobjects.com/wiki/Simplifying_Permissions_(Delphi).

Willian.