Skip to content

Instantly share code, notes, and snippets.

@benmay
Created April 24, 2013 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benmay/5450008 to your computer and use it in GitHub Desktop.
Save benmay/5450008 to your computer and use it in GitHub Desktop.
js cookies
jQuery(document).ready(function($)
{
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
if (agentID)
{
if( $.cookie('my_cookie_name') == undefined )
{
$.cookie( 'my_cookie_name', 'true', { expires: 30 });
if ( confirm( "You're on an mobile device, you should download our app." ) ) {
window.location = 'https://itunes.apple.com/....';
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment