API: 

<script src="https://pi-314159.github.io/jQuery/jQuery-3.1.1.min.js"></script>



Method 1: 
<script>
    if (document.cookie.indexOf("Language") < 0 ) {
        $.getJSON("https://picloud.xyz/Others/Language/", function(LANG){
            $.each(LANG, function(lang, Lang){
                $.ajax({
                    type: "POST",
                    data: ({Language: Lang})
                });
            });
        });
    }
</script>

<?php
if (isset($_POST['Language'])) {
    $cookie1_value = $_POST['Language'];
    if ($cookie1_value == 'error') {
        $cookie1_value = 'en';
    } else {
        $cookie1_value = substr($cookie1_value, 0, 2);
    }
    setcookie("Language", $cookie1_value, time() + (3600 * 8), "/");
}
?>


Method 2: 
<script src="https://tpicloud.github.io/JavaScript/Cookie.js"></script>
<script>
var lg = getCookie("Language");
if (lg !== '') {
} else {
    $.getJSON("https://picloud.xyz/Others/Language/", function(LANG){
        $.each(LANG, function(lang, Lang){
            var cookContent = Lang.substring(0, 2);
            if (cookContent == "zh") {
                setCookie("Language","zh","/");
            } else {
                setCookie("Language","en","/");
            }
        });
    });
    window.location.href=window.location.href;
}
</script>

© Pi TIAN. All rights reserved.