HTTP session ID

HTTP session ID is an optional non-negative integer which is attached to the session and any sockets it creates. The session ID is set on sockets by using RSocket::SetOpt() .

With this session ID, clients can specify an integer ID for an HTTP session, which is assigned to subsequent sockets. An ID that is set applies to subsequent socket connections.

HTTP session ID can be accessed using a Flow hook implementing the SetFlowOption() method, which is called whenever RSocket::SetOpt() is called. The Flow hook helps determine if a socket came from a specific session.

The session ID is set when the socket is created and is not changed. To find the session ID of a socket, the flow object must look for Set Option commands that request setting session ID. The ID that is set can be saved in the Flow hook object, and used later when needed. This can be done using an iSessionId variable to hold the value, as shown in the following example:

      
       
      
      #include <HTTPSocketConstants.h> // option consts defined here.... 
class CMip4Protocol : public CIp6Hook 
{ 
public: 
... 
virtual TInt SetFlowOption(TUint aLevel, TUint aName, const TDesC8 &aOption, CFlowContext &aFlow); 
private: 
...
TInt iSessionId; // session ID is stored here. Should be initialized to KErrNotFound
};
     

The HTTP session ID, HTTP::ESessionId , when set, is accessed using the session’s connection info object. For example:

      
       
      
      RHTTPSession session;
...
RHTTPConnectionInfo ConnectionInfo = session.ConnectionInfo();
     

To access the value, RString must first be extracted from the string pool. For example:

      
       
      
      RStringF sessionId = session.StringPool().StringF(HTTP::ESessionId, RHTTPSession::GetTable());
sessionId.Close();