Custom Session Management



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

CSP, besides the built-in Session Manager, supports external custom 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 _CSPSESMNG_GetSession( const CSPString& strAppID [IN], const CSPString& strSessionID [IN], CSPSession &Session [OUT]);
    This function is called by CSP 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 must return CSP_OK. If not found, it must 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 _CSPSESMNG_SetSession( const CSPString& strAppID [IN], const CSPString& strSessionID[IN], const CSPSession& Session [IN]);
    This function is called by CSP 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 must return CSP_OK. In case an unrecoverable error occurs during the execution, it must return CSP_ERROR_CANNOT_SAVE_SESSION_DATA.

  • bool _CSPSESMNG_Flush();
    This function is periodically triggered by CSP Engine in order to perform cleanup, session timeout or any other periodical process. If successful, it must return true. If an unrecoverable error occurs, it must return false. The implementation of this function is optional.

  • bool _CSPSESMNG_OnInitApp(const CSPString& strAppID);
    This function performs initialization tasks for the sessions of the application whose ID is contained in strAppID. It is called once, when the related application is loaded by CSP. If successful, it must return true. If an unrecoverable error occurs, it must return false. The implementation of this function is optional.

  • bool _CSPSESMNG_OnCleanupApp(const CSPString& strAppID);
    This function performs clean-up tasks for the sessions of the application whose ID is contained in strAppID. It is called once, when the related application is freed by CSP. If successful, it must return true. If an unrecoverable error occurs, it must return false. The implementation of this function is optional.

  • bool _CSPSESMNG_OnLoad(const CSPString& strAppID);
    This function performs initialization tasks for the entire Session Manager. It is called once, when CSP is loaded by the system. If successful, it must return true. If an unrecoverable error occurs, it must return false. The implementation of this function is optional.

  • bool _CSPSESMNG_OnUnload(const CSPString& strAppID);
    This function performs clean-up tasks for the entire Session Manager. It is called once, when CSP is unloaded by the system. If successful, it must return true. If an unrecoverable error occurs, it must return false. The implementation of this function is optional.

When implementing a Session Manager, you must include the files CSPVariant.h, CSPString.h, and CSPDefs.h. Also, you must link it to CSPLib.lib or libCSPLib.a, depending on the compiler in use. These files are placed in the "include" and "lib" directories of CSP Engine. See Control Console for more information about these directories.

It is important to notice that you must use the same compiler used by the installed version of CSP.

You must also compile with the option "/D _CSP_WINDOWS_", or you must define "#define _CSP_WINDOWS_" before you include any header file. Finally, the application manager DLL must export the functions above using symbols identical to the function names:
  • _CSPSESMNG_GetSession
  • _CSPSESMNG_SetSession
  • _CSPSESMNG_Flush
  • _CSPSESMNG_OnInitApp
  • _CSPSESMNG_OnCleanupApp
  • _CSPSESMNG_OnLoad
  • _CSPSESMNG_OnUnload
Online help home | Back
Copyright © 2002 - 2006 Micronovae Ltd. - www.micronovae.com