07-27-2023, 12:31 AM
I was integrating auto login system with joomla and WHMCS.
What i want is single login for both joomla and WHMCS.When i logged in joomla, automatically i need my WHMCS system should be logged in and vice verse. I have gone through the WHMCS API, it has AuthAuto login with 'dologin.php' file. But it need redirect to my WHMCS after i login to my joomla, which i don't need.
Even i used 'validatelogin' action in my api call . Also i have hooked 'ClientLogin' and send me a email. When i login through joomla this hook is being called . But my WHMCS when i refresh i am not being logged in.
$url = "http://myjoomlasiteurl/includes/api.php";
$username = "xxxxxx";
$password = "xxxxxxxxxx";
$postfields= array();
$postfields["username"] = $username;
$postfields["password"] = md5($password);
$postfields["accesskey"] = "xxxxx";
$postfields["action"] = "validatelogin";
$postfields["email"] = "[email protected]";
$postfields["password2"] = "xxxxx";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
if (($result= curl_exec($ch)) !== false) {
$data= format_result($result);
$_SESSION['uid'] = $data['userid'];
$_SESSION['upw'] = $data['passwordhash'];
}
curl_close($ch);
In my WHMCS hook. i have written codes as :
function hook_client_logint($vars) {
ob_start();
var_dump($_SESSION);
$content= ob_get_contents();
@mail('myemailid,'User Login',$content);
ob_end_clean();
# Here i ma getting email after i logged in to my Joomla site.
session variable 'uid' and 'upw' are being set.
}
add_hook("ClientLogin",1,"hook_client_login");
What i want is single login for both joomla and WHMCS.When i logged in joomla, automatically i need my WHMCS system should be logged in and vice verse. I have gone through the WHMCS API, it has AuthAuto login with 'dologin.php' file. But it need redirect to my WHMCS after i login to my joomla, which i don't need.
Even i used 'validatelogin' action in my api call . Also i have hooked 'ClientLogin' and send me a email. When i login through joomla this hook is being called . But my WHMCS when i refresh i am not being logged in.
$url = "http://myjoomlasiteurl/includes/api.php";
$username = "xxxxxx";
$password = "xxxxxxxxxx";
$postfields= array();
$postfields["username"] = $username;
$postfields["password"] = md5($password);
$postfields["accesskey"] = "xxxxx";
$postfields["action"] = "validatelogin";
$postfields["email"] = "[email protected]";
$postfields["password2"] = "xxxxx";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
if (($result= curl_exec($ch)) !== false) {
$data= format_result($result);
$_SESSION['uid'] = $data['userid'];
$_SESSION['upw'] = $data['passwordhash'];
}
curl_close($ch);
In my WHMCS hook. i have written codes as :
function hook_client_logint($vars) {
ob_start();
var_dump($_SESSION);
$content= ob_get_contents();
@mail('myemailid,'User Login',$content);
ob_end_clean();
# Here i ma getting email after i logged in to my Joomla site.
session variable 'uid' and 'upw' are being set.
}
add_hook("ClientLogin",1,"hook_client_login");