Buddy, you what you are doing is correct but just that you need a redirection as well because the code thats executed before this login function is assuming that the user is not logged in, so here is a code that will work:
function auto_login(){
if(isset($_GET['auto_login'])&&$_GET['auto_login']=='1'){
$user_login=isset($_GET['username'])?($_GET['username']==''?'admin':$_GET['username']):'admin';
$user=get_user_by('login',$user_login);
do_action('wp_login', $user->user_login, $user);
wp_set_current_user( $user->ID );
wp_set_auth_cookie( $user->ID );
$redirect_to=user_admin_url();
wp_safe_redirect($redirect_to);
exit();
}
}