Don't stash this globally. Instead, have this function take a callback function that receives the session (or error). This way you can programmatically use this without having multiple ones conflict, and callers can properly dispose the session when they don't need it.