Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// Функиция которая читает и записывает в куки
<script>
function checkCountry() {
var country = $.cookie("ad_country");
if ( country === undefined || country === "error" ) {
$.jsonp({
type: "GET",
url: "http://ipinfo.io",
callbackParameter: 'callback',
dataType: "jsonp",
timeout: 10000,
success: function(json){
$.cookie("ad_country", json.country, {expires: 7} );
},
error: function(){
$.cookie("ad_country", "error", {expires: 7} );
}
});
}
return country;
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment