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? Easily deploy an SSD cloud server on Digital Ocean in 55 seconds. Sign up using my link and receive $10 in credit!

blog comments powered by Disqus