Internet Direct (Indy) Version 9.0.1 Beta
DoCreateSession
Implements session creation or retrieval for client connections.

Description
DoCreateSession is a TIdHTTPSession function that implements the processing required for creating an HTTP session on the server. DoCreateSession is used when SessionState indicates that persistent state information is maintained using Cookies. If SessionState is False, the return value is Nil.

DoCreateSession will create a random session identifier for the client connection, and trigger the OnCreateSession event handler when assigned. OnCreateSession can be used when the HTTP server implementation needs to control creation of HTTP sessions, instead of relying on SessionList for session retrieveal or creation. OnCreateSession may assign, and add to SessionList, the HTTP session to be used for the threaded client connection.

When the HTTP session is not assigned in the event handler, SessionList is used to create or retrieve a HTTP session for the remote IP address in HTTPRequest.

DoCreateSession also sets a Cookie, named using the value in GSessionIDCookie, in HTTPResponse that contains the session identifer for the HTTP session. The Cookie name will be applied to all resources for the Domain and expires when the HTTP session ends.

DoCreateSession assigns the HTTP session in the return value for the method to both HTTPResponse.Session and HTTPRequest.Session.

DoCreateSession is called when the HTTP server executes the thread for the client connection, and AutoStartSession indicates that a session should be retrieved using the cookie values in the HTTP request.