Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You can use the “S4SPersistedLogin” cookie to identify the visitor if they return to the website at a future date. The identification is possible because the Salesforce lead Lead (or contactContact) record (created when the WFFM form was submitted) contains a unique (and configurable) field that transparently logs the user ininto the Sitecore website. This functionality requires the S4S Security Provider be installed (in this scenario the Sitecore website may or may not have traditional authentication via a login control).

If you do not want to uses the “S4S Push Visitor” Submit Action you can create your own custom functionality. The S4SPersistedLogin methods can be found in the PersistedLogin class in the FuseIT.S4SMapping.dll assembly. Its exposes the following methods:

Create Cookie

Use the following static method to create a cookie. This method is used in the “S4S Push Visitor” Submit Action but can also be accessed on a custom form.

Code Block
languagec#
PersistedLogin.CreateLoginCookie(visitorId, loginUserName, expires);
 

Auto-Login

After a cookie is created, we need to identify and login the returning visitor:

Code Block
languagec#
PersistedLogin persistedLogin = new PersistedLogin(Request);
string userLoginName = string.Empty;
if (persistedLogin.ValidateLoginCookie("salesforce", out userLoginName))
{
Sitecore.Security.Authentication.AuthenticationManager.Login(userLoginName);
}
 

Logout

There are two types of logout. Permanent logout will delete the “S4SPersistedLogin” cookie while another creates a new cookie to block auto login. The block cookie will be removed when the user’s session ends, so next time user comes back, that user will be able to auto login again.

...