'logging into moodle "remotely"

i try to log into the selfhosted moodle website without using the login form. More kinda like an SSO login, without the external service. more with a post request with the login credentials, so when i open the site "later" i'm allready logged in, or can request the current logged in user somehow.

i tried to

  1. create an auth plugin - and failed gracefully - it's installed but not used by system..
  2. create a page that recieves post data and "simulates" form post to login url - not accepted - csrf not accepted
  3. create the session cookie "external" with a file/page inside moodle - cant find correct moodle cookie creation process

i tried to immitate the set_moodle_cookie function of moodle, but the cookie i make is everytime with different domain name (dot in front) and even then this function isn't used by the login... (commented it out and it still works normal).

  1. so where in moodle is the function that creates the session cookie to let the system know if and which user is logged in, so i can "fake it"? can anyone give me a hint for direction?

(2. how to set cookie without "." in front of domain name)

  1. any better solution to remotely log into website of moodle without external services? (sending data with post?)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source