Custom Session Management



The Session Manager, is a mechanism that provides client bound information through the Session intrinsic object (class CSPSession).

The CSP engine, besides the built-in Session Manager, it supports external or third party Session Managers. Although the way a Session Manager is implemented is up to the developer, there are a few implementation rules:

The Session Manager is a DLL that must implement and export a few functions:
  • CSPERROR GetSession( const CSPString& strAppID [IN], const CSPString& strSessionID [IN], CSPSession &Session [OUT]);
    This function is called by the CSP Engine to retrieve session information. The string strAppID contains the unique ID of the application that the requested .csp script belongs to, and the string strSessionID contains the client's session ID. The function must search for the session information using the strSessionID and strAppID as keys, and store the information in the Session object. If the session information is found and successfully put in the Session object, the function should return CSP_OK. If not found, it should return CSP_SESSION_DATA_NOT_FOUND. In case an unrecoverable error occurs during the execution, it must return CSP_ERROR_CANNOT_RETRIEVE_SESSION_DATA.

  • CSPERROR SetSession( const CSPString& strAppID [IN], const CSPString& strSessionID[IN], const CSPSession& Session [IN]);
    This function is called by the CSP Engine to save session information. The string strAppID contains the unique ID of the application that the requested .csp script belongs to, and the string strSessionID contains the clients's session ID. The function must save the session information in any manner preferred, using strAppID and strSessionID as keys for later retrieval. If the session information is successfully saved, the function should return CSP_OK. In case an unrecoverable error occurs during the execution, it must return CSP_ERROR_CANNOT_SAVE_SESSION_DATA.

  • bool Flush();
    The implementation of this function is optional. It is periodically triggered by CSP Engine in order to perform cleanup, session timeout or any other periodical process. If successful, it should return true. If an unrecoverable error occurs, it should return false.
When implementing a Session Manager, you must include the files CSPSession.h, CSPString.h, and CSPDefs.h. Also, you must link it to CSPLib.lib. These files can be found in the “include” and “lib” directories of the CSP Engine. See Control Console for more information about these directories.
Online help home | Back
www.micronovae.com

Copyright © 2002 - 2005 Micronovae Ltd