2013-06-01 42 views
1

我有一個Sitecore 6.6站點和一個Extranet。 我怎樣才能在登錄表單中添加自動登錄功能?Sitecore外聯網自動登錄?

var domain = Sitecore.Context.Domain; 
var domainUser = domain.Name + @"\" + Request["username"]; 
if (Sitecore.Security.Authentication.AuthenticationManager.Login(domainUser, Request["password"], false)) 
{ 
    // SUCCESS 
} 

回答

4

在您的登錄表單中,您需要提供一個複選框,然後檢查它是否被選中。當你登錄的布爾標誌指示是否要堅持會話之間登陸:

Sitecore.Security.Authentication.AuthenticationManager.Login(domainUser, Request["password"], true) 

您還需要更新您的web.config你想要的「記住我」的時間量的cookie持續1天= 1440分鐘:

<authentication mode="None"> 
    <forms name=".ASPXAUTH" cookieless="UseCookies" timeout="1440" /> 
</authentication> 

http://mazdev.blogspot.ca/2011/06/sitecore-authentication.html