I'm setting up a single-sign-on feature for moodle from a laravel website.
User accesses the laravel site
User logs in
User clicks a link to Moodle
- The user is automatically logged into Moodle without having to reenter their username and password.
If the user bookmarks or directly accesses Moodle, they can still login directly there with their username and password.
I have tried to user php cURL to post username and password to the login url.
$url = "http://moodle.site.com.na/sso/login/index.php";
$postData = array('username' => $username, 'password' => $password);
try {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
}
catch(Exception $e){
dd($e);
}
return $response;
When the single-sign-on is successful, then the user should be automatically logged into moodle site without having to re-enter their username and password.