Parookie.js is an MIT-licensed JavaScript package/script that creates a cookie from every url parameter (?name=value
) using URLSearchParams(window.location.search)
browser:
<script src="function.js"></script>
<script>
cookify(expirationTime, useSessionStorage, whitelist, debug)
</script>
npm:
npm i parookiejs
node.js:
var parookie = require('parookie');
bower:
bower install EthanMcBloxxer/parookiejs
yarn:
yarn add parookiejs
requirejs:
require({'paths': {'parookie': 'path/to/parookiejs'}}, ['parookiejs'], function(x) {console.log(x);});
This is the main function for parookie, which converts the url parameters into cookies.
In miliseconds, the expiration time of the cookie. Set to 0
to disable and make the cookie permanent. 1
-1000
is a good option for keeping the cookie on just page load.
true: Use sessionStorage
instead of cookies
false: Don't impact the script
Add values to this for them to be the only creatable cookies, like ["1", "2"]
. Leave as []
to disable.
Log to the console when an event completes
require("function.js");
cookify(0, false, [], false);