Skip to content

Instantly share code, notes, and snippets.

@andreibabor
Last active March 25, 2019 11:54
Show Gist options
  • Select an option

  • Save andreibabor/942bea9c544f2f185a8436a4705c8ba9 to your computer and use it in GitHub Desktop.

Select an option

Save andreibabor/942bea9c544f2f185a8436a4705c8ba9 to your computer and use it in GitHub Desktop.
IP Redirect with cookie to visit 1st time
//mai trebuie adaugat js.cookie.js
//mai multe info https://alexcican.com/post/set-cookies-javascript/
{% if settings.redirect_use %}
{{ "js.cookie.js" | asset_url | script_tag }}
{% include 'redirect-message' %}
{{ 'redirect.js' | asset_url | script_tag }}
<script>
$(document).ready(function() {
//match cookie
if ($.cookie('mycookie') == 'yes') {
console.log('set cookie enabled');
}
else{
//set cookie
$.cookie('mycookie', 'yes', {expires: 1 });
//check cookie and init IP Redirect
if ($.cookie('mycookie') == 'yes') {
IPRedirect.init({{ settings | json }});
IPRedirect.run();
console.log('IP Redirect RUN');
}
}
});
</script>
{% endif %}
@andreibabor
Copy link
Author

//mai trebuie adaugat js.cookie.js
//mai multe info https://alexcican.com/post/set-cookies-javascript/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment