Using hooks to detect a Web session

You can use the predefined _CQ_WEB_SESSION session variable to detect whether a user is on a Web browser or an installed HCL Compass client. This allows you to take appropriate action if you have not adjusted your schema to match the functionality available on the Web. For example, when you detect a Web session in a function that creates a message box or a new window, you can call code modified for the Web environment or exit the function.

  • Web session detection in VBScript:
    dim currDBSession                 ' Current Db session
    set currDBSession = GetSession
    ' Test for existence of the web session variable
    if currDBSession.HasValue ("_CQ_WEB_SESSION") then
       ' Either exit or do something else
    end if
    
  • Web session detection in Perl:
    my $currDBSession;   # Current Db session
    $currDBSession = $entity->GetSession();
    # Test for existence of the web session variable
    if ( $currDBSession->HasValue ("_CQ_WEB_SESSION") {
       # Either exit or do something else
       }
    

Functions, such as a message box, that call other Windows™ applications cause the Web client to freeze. For example, if a message box function runs on a Web server, the message box pops up on the server's screen. Because the user cannot click OK on the server, the client is left waiting. This requires you to reboot the Web server. If record scripts return a string value, that string is displayed to the user.