Cookie value changes back to previous value after changing

I didn’t see this happening on your site, but I think you could probably remove the variable declaration in front of setcookie(). I didn’t see result called used any where in this code. Which makes me wonder if the value is being set because since the variable isn’t used.

<?php
    
    add_filter( 'init', 'aws_set_language_cookie', 999 );
    function aws_set_language_cookie() {
        global $TRP_LANGUAGE;
        if ( isset( $TRP_LANGUAGE ) ) {
            setcookie( 'language', $TRP_LANGUAGE, time() + ( 30 * DAY_IN_SECONDS ), "/", "" , true, true );
        }
    }
    ?>

I hope this helps, sorry if it doesn’t 🙂