WordPress auto login from custom page

Solution:

You should use the core function wp_signon https://codex.wordpress.org/Function_Reference/wp_signon this is the sample code

function custom_login() {
    $creds = array();
    $creds['user_login'] = 'example';
    $creds['user_password'] = 'plaintextpw';
    $creds['remember'] = true;
    $user = wp_signon( $creds, false );
    if ( is_wp_error($user) )
        echo $user->get_error_message();
}