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!

Published: June 11, 2013

Need hosting? I use and recommend a Digital Ocean SSD VPS server! Check out my referral link below:

Get an awesome virtual SSD server cheap!
blog comments powered by Disqus