TsgcWebSocketHTTPServer › Properties › SessionClass
Class used by the server to create new HTTP sessions; set it to your own TIdHTTPSession descendant to store custom data in every session.
property SessionClass: TsgcIdHTTPSessionClass read GetSessionClass write SetSessionClass;
// TsgcIdHTTPSessionClass = class of TIdHTTPSession
TIdHTTPSession
By default the server creates plain TIdHTTPSession objects. Set SessionClass to a descendant of TIdHTTPSession and the server will create that class instead, for every session, including the ones created automatically when AutoStartSession is enabled. The unique session ID, the session cookie, SessionTimeOut and the removal of stale sessions keep working exactly as before.
Override the virtual constructor CreateInitialized in your descendant if you want to initialize your own fields when the session is created. Read the session back from ARequestInfo.Session and cast it to your class.
SessionClass must be set before the server is activated, and it cannot be nil. If you assign your own SessionList, this property no longer applies, because your list decides which class to create. See Sessions for a full explanation, and note that the OnCreateSession event is not the recommended way to change the session class.
type
TMySession = class(TIdHTTPSession)
private
FUserName: String;
public
property UserName: String read FUserName write FUserName;
end;
oServer := TsgcWebSocketHTTPServer.Create(nil);
oServer.SessionState := true;
oServer.SessionTimeout := 600000;
oServer.SessionClass := TMySession;
oServer.Active := true;