I am investigating using Sitecore virtual users so that I can authenticate with an external system and log users in that way. However, I also need to be able to support the persistent flag. Currently my code looks something like this:

       var virtualUser = AuthenticationManager.BuildVirtualUser($"domain\\{username}", true);
        //setup custom properties we want in user
        virtualUser.Profile.Name = memberData.FirstName;
        virtualUser.Profile.FullName = $"{memberData.FirstName} {memberData.LastName}";


However, the AuthenticationManager class doesn't have a persistent option for logging in virtual users. Is there a reason why persisting virtual user logins is bad/unsupported? What is the recommended workaround? I'm guessing I'll need to setup a concrete membership provider but wanted to see if there is another viable workaround.

2 Answers 2


As mentioned already, a Virtual user is transitory - it cannot be persisted from visit to visit.

So you need to look at this differently. When integrating with an external authentication service, such as ADFS or Azure AD - the login persistence occurs with the authentication service, not in Sitecore.

So when the user goes to a secured page in Sitecore - your code that integrates with the auth service would kick in and redirect the user to the login process - if the user is already logged in, that would then send back the authentication approval and you would run through your code to create the Virtual User etc...

To the users perception - they are just logged in automatically. It would add complexity to go down the route of having a concrete membership provider when using an external auth service. You would have to sync the users, sync password changes etc... lots of things to go wrong. Letting the service handle the persistence makes the process a lot simpler.


Sitecore does not support persistent login for virtual users by design. Virtual users are transitory; they do not persist on the system after the user logs out or their seesion ends. The idea of virtual users is to provide a one time access to the system.

  • We do have an option with OWin configuration with DefaultExternalUserBuilder, i.e. <param desc="isPersistentUser">true</param>. Thus i guess, we should also have an option to create it through custom code. Any clue? Commented Aug 27, 2018 at 13:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.