Versions Compared

Key

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

...

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:

...

Creating a 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);

...

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);
}

...

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.

 

Code Block
languagec#
/// <summary>
/// Permanent log out
/// </summary>
PersistedLogin persistedLogin = new PersistedLogin(Request);
persistedLogin.PermanentLogoutUser();
 
/// <summary>
/// Create a cookie to block auto logins
/// </summary>
PersistedLogin persistedLogin = new PersistedLogin(Request);
persistedLogin.LogoutUser();