Okay, I've been digging through hundreds of articles trying to find an answer. I have been able to find answers somewhat close to what I am looking for, but nothing that is exactly what I am looking for.

What I am trying to do is this;
I want to set up a website (Site A) that has a Username and Password field, which the potential user will enter the Username and Password to another site (Site B) and it will take the data entered into the Username and Password Fields on Site A and enter those values into the Username and Password boxes on site B. Once this is accomplished Site A will remain 'logged in' to Site B, and log out when the session is terminated.
Originally I thought PERL would be the best way to go about doing this, then I discovered cURL with PHP. If possible, I would like to use cURL since both sites are almost entirely PHP as is.

I am not entirely sure how I would go about this, and any help would be greatly appreciated!