Using the following snippet in your theme’s functions.php file, you will be able to log-in a WordPress user programmatically.

Snippet Source/Credit: emoticode