Wie kann _forum_session und _t für einen Benutzer durch Code/API-Aufruf oder ohne Browser-Login generiert werden?

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.