1. User browses my site 2. User clicks on a link which completes a task on external website (such as logs in) called "Site B" - this bit needs to be invisible to the user 3. User carries on browsing my site. 4. When user has finished on my site they click on a link that takes them to Site B 5. When they arrive at site B they are already logged in because I did that in step 2.
I have been doing step 2 with an invisible IFRAME but some sites have not worked correctly.
Therefore what other methods can I use? I have looked fsockopen and curl but this doesn't seem to work because the Session or cookie is created on my server not the users browser and therefore when they get to site b the action required hasn't been completed.
Maintaining session state between two separate domains is not an easy task. If they are both on the same domain (subdomains) your life would be much easier because you can manage state via the cookie itself.
If they are on different domains entirely, you are looking into what is commonly referred to as SSO or single sign-on. It is a large undertaking. Here are a couple of threads that might give you some other ideas as to how you might proceed.