Programmatically Logging In a User in Kentico
You’re using Kentico CMS and you need to log someone in. Maybe you’re doing a custom registration form, or an OAuth integration. Whatever the case, it’s super easy. You simply call the AuthenticateUser
static method on the CMSContext
class. Here is the method signature:
public static void AuthenticateUser(string userName, bool createPresistentCookie);
And this is how you would call it:
CMSContext.AuthenticateUser("my username", true);
Piece of cake!