I need to seamlessly and silently pre-login users from my primary sub-domain into my Moodle instance (on a friendly sub-domain). I remotely post my custom login/index.php passing user credentials into it and need to return MoodleSession cookie to set it in a requesters browser session.
I successfully retrieve MoodleSessionTest cookie value, however MoodleSession cookie comes back blank, even though I do see that the both cookie values are successfully set in the browser as a result of script run.
Could someone please help me understand behavior of MoodleSession cookie and capture its value?
I have a fresh Moodle installation (2 months old). Here is a code extract from my custom login/index.php :
###################################################################################
print_footer();
exit;
} elseif (intval($days2expire) < 0 ) {
print_header("$site->fullname: $loginsite", "$site->fullname", $navigation, '', '', true, " ");
notice_yesno(get_string('auth_passwordisexpired', 'auth'), $passwordchangeurl, $urltogo);
print_footer();
exit;
}
}
reset_login_count();
/ *Capture session cookie
MoodleSessionTest cookie value is captured, MoodleSession is blank(null?)
*/
echo 'Check Cookie:
';
echo 'MoodleSessionTest
';
echo $_COOKIE['MoodleSessionTest'.$CFG->sessioncookie];
echo '
MoodleSession
';
echo $_COOKIE['MoodleSession'.$CFG->sessioncookie];
die();
redirect($urltogo);
exit;
} else {
if (empty($errormsg)) {
$errormsg = get_string("invalidlogin");
$errorcode = 3;
}
// TODO: if the user failed to authenticate, check if the username corresponds to a remote mnet user
if ( !empty($CFG->mnet_dispatcher_mode)
&& $CFG->mnet_dispatcher_mode === 'strict'
###########################################################################
Only MoodleSessionTest cookie is returned in the custom intex.php outup, while all cookies are set in the browser
