views:

67

answers:

3

I would like to be able to click a link in Website A that will autofill a username and password into Website B.

Can anybody provide me some ideas how to do this with JavaScript or PHP?

Many thanks!

+2  A: 

I am not sure what you mean by your question. Have you tried looking at OpenSocial or OpenID?

Nican
Thanks for your response Nican. I'm not sure that that will help me :(I have a client who has only one login to a site they subscribe to.All of their staff use this one login to access that site.I need to be able to link from their website (website A) and have the login fields on website B (the site they subscribe to) automatically filled in when they land on that page.Possible?
matchstic
@matchstic, nope, impossible.
Col. Shrapnel
+2  A: 

If you're able to edit website B, you can try to add a query string contains username and password to link and on website B get them from url and echo into input field's value attribute.

#Sample url on website A:
http://www.example.com/?username=admin&password=1234

#Simple sample form on website B:
<form>
    <input type="text" value="<?php echo $_GET['username']; ?>" />
    <input type="password" value="<?php echo $_GET['password']; ?>" />
    <input type="submit" />
</form>
gasoved
+1 but,should encrpt/decrpt the username,password before/after passing.
Kai
A: 

As someone else mentioned before the cleanest solution is to use a credential token.

  1. User logs in on Site A.
  2. Site A inserts a credential token in Site B's database - either by directly contacting the database of Site B or by calling a URL or an API in the background. This credential token will contain a unique token identifier (usually a long string, possibly obtained from md5-ing something) and the username and password of the user on Site B.
  3. When the user is presented links to Site B on Site A all of them end with &token=123456789abcdef0
  4. When the user arrives on Site B and the URL contains the token mentioned, username and password are extracted from the token in Site B's database and prefilled in the login box.

Tweak this to your liking.

kitsched