The scenario you are describing can be tricky. The main problem you are facing is how you send login credentials to site B so that the cookies returned by the successful login go to the user browser and belong to site B, so site B receives them when the user is actually navigating.
Several people suggested that the form be submitted to a PHP file on your server and allow them to log in from server to server. This solution almost never works. Even if site B accepts your server-to-server login (which will probably be how you can fake any browser you want), it will be your web server, which will receive new cookies, and your web server IP, with which the session will be associated. Even if you return the cookie to the browser, it will save it for your site (site A) and will not send it to site B when the browser gets there, so the user will remain in site B.
So, the only thing you can do here is post the login form for your site on your server. This means that you will need to submit the form to a browser that has an ACTION that points to the login form of site B. It also means that whenever the user clicks the login button, the control is transferred to site B: user will move from your site and you will lose it.
There are two main technical problems in this second method: one of them is that site B may have an XSS warning and actually blocks you from publishing material on the login page. Another problem is that if your site is in SSL mode, browsers will take a long time to click to submit the form to another website. None of this can decide.
The only clean solution is to really go to Site B and create a general authentication plan, or at least an authentication API. You can try the solution at the intersection of the form, but there are good chances that you will have problems with it that you do not like.
CodeTwice
source share