Jump to content

Auto login not working correctly using API validatelogin. Any help?


sufi

Recommended Posts

I am trying to set auto login from wp to my whmcs site using WHMCS API. Everything is working perfectly, except, it is not let me login automatically.

 

my wp url: wp.domain.com (ip 1) whmcs url: domain.com (ip 2)

 

They are on different IP. so I have used cookie. I have called the validatelogin from wp and it returns uid and upw hash perfectly, which needs to be set on two session variable. But as I am on two different server, I have set them on two different cookie.

 

Now I put this code in top of my whmcs header:

 

{if !$loggedin}
{php}
   session_start();
   $_SESSION['uid'] = $_COOKIE['uidwp'];
   $_SESSION['upw'] = $_COOKIE['upwwp'];
{/php}
{/if}

 

But when I refresh the page, it does not login me, even it does not let me login using my username and passowrd (of whmcs), when cookie is set. I checked the cookie by printing the value in the whmcs site. And it shows correct value. It only works, if I restart the browser (i have set cookie to destroy when browser is closed), do not login to wp site (so no cookie set), then I can login to whmcs site using my username password. Now (keeping whmcs logged in), if I go to wp site, and then log out from the whmcs site, and if i refresh the page, I am auto logged in! But it should have work whenever the cookie is set. Any solution please?

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