Skip to content

Instantly share code, notes, and snippets.

@goranefbl
Last active October 7, 2015 05:58
Show Gist options
  • Save goranefbl/6f370cc3bef3601e3df8 to your computer and use it in GitHub Desktop.
Save goranefbl/6f370cc3bef3601e3df8 to your computer and use it in GitHub Desktop.
Cookie GET example
(function( $ ) {
'use strict';
//Javascript GET cookie parameter
var $_GET = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
function decode(s) {
return decodeURIComponent(s.split("+").join(" "));
}
$_GET[decode(arguments[1])] = decode(arguments[2]);
});
// Get time var defined in woo backend
var $time = parseInt(plugin_name.timee);
//If raf is set, add cookie.
if( typeof $_GET["raf"] !== 'undefined' && $_GET["raf"] !== null ){
//console.log(window.location.hostname);
cookie.set("gens_raf",$_GET["raf"],{ expires: $time });
}
})( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment