Como gerar _forum_session e _t para um usuário através de código/chamada de API ou sem login no navegador?

If what you are trying to do is to let people log in to Discourse using your other app, or to log in to your other app using Discourse, then you want to implement DiscourseConnect, that I linked to above. You can see that page for documentation and code examples.