TsgcHTTPServer › 属性 › SessionState
在无状态 HTTP 协议之上启用基于 Cookie 的 HTTP 会话跟踪。
property SessionState: Boolean read GetSessionState write SetSessionState;
False
将 SessionState 设置为 True,允许 HTTP 服务器为每个客户端分配会话 id,并在 SessionList 集合中维护每用户状态。OnSessionStart、OnSessionEnd、OnCreateSession 和 OnInvalidSession 事件为实现登录流程提供挂钩点。调整 SessionTimeOut 以控制空闲过期,并结合 AutoStartSession 在首次请求时自动创建会话。完整演示请参阅 HTTP 服务器会话主题。
oServer := TsgcHTTPServer.Create(nil);
oServer.SessionState := true;
oServer.AutoStartSession := true;
oServer.Active := true;