2017-03-08 152 views
0

的情況下使用javascript我有一個網站,生成會話ID,並打開本次會議的背景中另一個網站id.i想要一個按鈕,打開第一個網站,比automaticaly登錄第二個站點上。登錄會話ID

網站1:http://thisisanexample/example導致http://thisisanotherexample/another

本打開的第一位置和第二位點之後打開: VAR mywindow的;

function openWin() { 
myWindow = window.open("http://thisisanexample/example"); 
} 
</script> 

在這裏我卡住了。我怎麼能提交下列POST請求網站2

<form action="http://thisisanotherexample/another/" method="POST" name="logonForm"> 
    <input type="text" name="user" value="placeholder"> 
    <input type="hidden" name="passwordnew1" value=""> 
    <input type="hidden" name="passwordnew2" value=""> 
    <input type="password" name="password" value="placeholder"> 
    <input type="hidden" name="welcomescreen" value="1"> 
    <input type="submit" value="Anmelden" name="cmd_login"> 

我希望你明白我的意思:-)

+1

您嘗試實施的功能稱爲「單一登錄」。這篇文章可以幫助你:https://auth0.com/learn/how-to-implement-single-sign-on/ –

回答

1

您可以使用:

window.location.href = "http://www.example.com/otherSite?name=ferret"; 

導航到第二個站點,而通過查詢字符串參數傳遞用戶名和密碼。第二個站點將有某種方法來接受這些參數,並自動登錄的用戶。我們強烈建議您在查詢字符串數據加密不知何故。

https://en.wikipedia.org/wiki/ROT13