The `getSession` function defined in the hook is asynchronous and the server load of the layout was not awaiting it, therefore, it was sending a promise instead of the session. Added `await`.