Membership auto-login

Seems to me that after a user registers using the membership plugin and selects a subscription, they should be automatically logged in like so:

<?php
add_action( 'membership_subscription_form_after_subscriptions', 'membership_autologin' );

function membership_autologin($user_id) {
  if($user_id && function_exists('wp_set_auth_cookie')) {
    wp_set_auth_cookie($user_id);
  }
}

?>