TsgcWebSocketHTTPServer › Properties › AutoStartSession
当启用会话状态时,为每个传入请求自动创建新的 HTTP 会话。
property AutoStartSession: Boolean read GetAutoStartSession write SetAutoStartSession;
False
当 SessionState 和 AutoStartSession 均为 True 时,HTTP 服务器在首次看到没有有效会话 Cookie 的请求时,会自动分配一个新的 TIdHTTPSession(并触发 OnSessionStart),因此服务器代码无需显式调用 CreateSession()。如果您希望在处理程序代码中决定是创建会话还是拒绝请求,请将此项保留为 False。当 SessionState 为 False 时,此属性无效。
oServer := TsgcWebSocketHTTPServer.Create(nil);
oServer.SessionState := true;
oServer.AutoStartSession := true;
oServer.SessionTimeOut := 600000;
oServer.Active := true;