@firstandthird/cookie-monster

    3.2.0 • Public • Published

    Cookie Monster

    Build Status npm

    Cookie manager

    Installation

    npm install @firstandthird/cookie-monster

    Usage

    import CookieMonster from '@firstandthird/cookie-monster';
     
    const name = 'cookiename'; // required
    const value = 'somevalue'; // required - may also be an object
    const expires = 10; // optional - Days cookie is valid
    const path = '/test'; // optional - defaults to /
    const domain = 'blog.example.com'; // optional
    const isSecure = false; // optional - sets secure flag
    const sameSite = 'Strict'; // optional - defaults to 'Strict' - Valid values: 'None', 'Lax', 'Strict'
     
    // Set cookie
    CookieMonster.set(name, value, expires, path, domain, isSecure, sameSite);
     
    // Get cookie
    CookieMonster.get(name);
     
    // Remove cookie
     
    CookieMonster.remove(name);
     
    // Increment a counter cookie
    CookieMonster.increment(name, expires);
     
    // Decrement a counter cookie
     
    CookieMonster.decrement(name, expires);

    Methods can also be imported as needed:

    import { get, remove } from '@firstandthird/cookie-monster';
     
    get(name);
     
    remove(name);

    Install

    npm i @firstandthird/cookie-monster

    DownloadsWeekly Downloads

    8

    Version

    3.2.0

    License

    MIT

    Unpacked Size

    12.1 kB

    Total Files

    12

    Last publish

    Collaborators

    • alaguna
    • aleperez92
    • dawnerd
    • ecwillis
    • jga
    • orthagonal1