CometChat integration
The Matt's answer was pretty complete and worked almost, but for the benefit of others, there is the changes required files to make it works:

in integration.php

find

define('SET_SESSION_NAME','');


change for

define('SET_SESSION_NAME','CraftSessionId');


and make your getUserID functions look like

function getUserID() {
            $userId = 0; // Return 0 if user is not logged in

            if ( $_SESSION[ 'craftUserId' ] ) 
            {
                $userId = $_SESSION[ 'craftUserId' ]; // Set this session variable in a Craft plugin
            }

            return intval( $userId );
    }


and in a Craft plugin, add this to a init() function

public function init()
    {            
        craft()-&gt;on('userSession.onLogin', function(Event $event) {
            $currentUser = craft()-&gt;userSession-&gt;getUser();
            craft()-&gt;httpSession-&gt;add( 'craftUserId', $currentUser ? $currentUser-&gt;id : null );            
        });
   }


If you want to be full-padded, you can also add something to unset your CraftUserId variable onLogout event, but I don't think it's needed.

Thanks a lot to Matt and Brad who helped me out on Easter day!