Jump to content

Login to WHMCS from external


Recommended Posts

I followed the API documentation to validate a login [1], which works fine for me.

However, when I set the session variables $_SESSION['uid'] and $_SESSION['upw'] as described there, with the returned userid and passwordhash from the validate login API call, I am not automatically logged in to WHMCS.

 

Via the forums I found that the passwordhash is (or was once?) computed as follows:

$_SESSION['upw'] = md5($userRow['id'] . $userRow['password'] . $_SERVER['REMOTE_ADDR']);

 

Because the API is not called from the clients IP but a servers IP, I suppose that this might cause it not to work. However, even if I create the $_SESSION['upw'] hash as described above I am not automatically logged in.

 

To verify the hashs I obtained the $_SESSION['upw'] variable after a regular login to WHMCS which indeed turns out to be different to the one I am returned by the API call validate login, as well as the manual construction.

 

Later I discovered AutoAuth [3]. It works for the first page of WHMCS that I enter. However, when I go to other pages of WHMCS the login seems to get lost again.

 

I even disabled Session IP Checking in the general settings -> security, without success. Also, the timestamp that I use with AutoAuth has the same time as the server time.

 

Does someone know how this can be succesfully done? Or how I can debug this process in any way in more detail?

Thanks

Link to comment
Share on other sites

I wouldn't use the session based authentication, that will only really work if the other application is on the same domain unless you tweak the cookie to save under the whmcs domain and can just be difficult to work with in general.

 

That being said, your best bet is to continue to try and get AutoAuth to work instead. Make sure you have disabled your other code that is changing the session variables just in case that is conflicting with AutoAuth and exit out of your browser completely to clear out any session cookies and try your autoauth again.

Link to comment
Share on other sites

Thanks for your help. I tried to clear my browser data, session cookies etc. but without success.

I do put some other variables from external in the $_SESSION, but after I go from my site to WHMCS, WHMCS will overwrite any variables that may have conflicting names with my site, right? So if then I have an issue in WHMCS, I don't think it can be because of a conflict there?

 

Why does it work for the first page I enter in WHMCS, and a second one the session information is lost? Any ideas on this detail?

 

Here are the $_SESSION variables of the first site:

array(9) { ["email"]=> &string(17) "some@one.net" ["uid"]=> &string(1) "7" ["upw"]=> &string(32) "a4cd87549233cf900f8d83e617206e8d" ["Language"]=> &string(7) "english" ["calinkupdatecc"]=> &int(0) ["calinkupdatesq"]=> &int(0) }

 

And here, of another one if I continue to navigate in WHMCS:

array(3) { ["calinkupdatecc"]=> &int(0) ["calinkupdatesq"]=> &int(0) ["loginurlredirect"]=> &string(36) "/dach/clientarea.php?action=products" }

Edited by thomas.rodriguez
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated