1.2.1 • Published 5 years ago
parookiejs v1.2.1
parookiejs
Parookie.js is an MIT-licensed JavaScript package/script that creates a cookie from every url parameter (?name=value) using URLSearchParams(window.location.search)
Installation
browser:
<script src="function.js"></script>
<script>
cookify(expirationTime, useSessionStorage, whitelist, debug)
</script>npm:
npm i parookiejsnode.js:
var parookie = require('parookie');bower:
bower install EthanMcBloxxer/parookiejsyarn:
yarn add parookiejsrequirejs:
require({'paths': {'parookie': 'path/to/parookiejs'}}, ['parookiejs'], function(x) {console.log(x);});API
cookify()
This is the main function for parookie, which converts the url parameters into cookies.
int expirationTime
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.
bool useSessionStorage
true: Use sessionStorage instead of cookies
false: Don't impact the script
array whitelist[]
Add values to this for them to be the only creatable cookies, like ["1", "2"]. Leave as [] to disable.
bool debug
Log to the console when an event completes
Example
require("function.js");
cookify(0, false, [], false);