add query string to all pages after user logged in

add following code to functions.php,

add_action('wp_head', 'your_function');
function your_function(){
    if ( is_user_logged_in() ) {
        $genre_url = add_query_arg('aff', '1234567', get_permalink());
    } 
}

Hope this will help you.
for more information,

error code: 523