Getting a Session object

The Session object is the entry point for accessing HCL Compass user databases. For Compass hooks, a Session object is created automatically when a user logs on to the database, and is available through the Entity object. If you are writing an external application, you must create a Session object and use it to log on to a database.

After you have logged on to a database, you can use the Session object to:
  • Create new records or queries
  • Edit existing records
  • View information about the database
In the context of a hook, to get a Session object from an Entity object, use the following syntax.
  • VBScript:
    set currentSession = GetSession
    VBScript hooks implicitly associate the Entity object with the current record.
  • Perl:
    The Session object is created and made available through the context variable, $session. You do not need to perform any explicit call to create it. You can get a Session object by using the following syntax, if you already have a valid Entity object:
    $session=$entity->GetSession();
The GetSession method returns the current Session object.
  • Inside a hook you do not need to first construct the Session object.
  • In external applications, you must first create the initial Session object. You can use the GetSession method if you already have a valid Entity object.
For external applications, you must create a Session object, if you do not have an Entity object. If you want to use the AdminSession object, the same rule applies.
  • VBScript:
    set currentSession = CreateObject("CLEARQUEST.SESSION") 
    set adminSession = CreateObject("CLEARQUEST.ADMINSESSION")
  • Perl:
    $currentSession = CQSession::Build(); 
    $currentAdminSession= CQAdminSession::Build();

    When you are done with the object, destroy it:

    CQSession::Unbuild($currentSession);
    CQAdminSession::Unbuild($currentAdminSession);