npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cookie-micro

v1.0.1

Published

JavaScript Cookie micro library

Downloads

10

Readme

CookieJS

CookieJS - Just another small JavaScript library. Use this if you need to set/get/delete cookies.

This library is now pushed to NPM, and is available as an UMD build.

$ npm i --save cookie-micro

UNPKG

<script src="//unpkg.com/cookie-micro/cookie.min.js"></script>

No jQuery needed.

How to use:

  • name = cookie name
  • value = value of the cookie
  • expire = days before it expires
  • path = path of the website. '/' for whole site.
  • (Optional) domain = ex: domain.com. If not set, it would be available for all subdomains.
  • (Optional) secure = Use SSL while transferring cookie to server
  • (Optional) httpOnly - Using the HttpOnly flag when generating a cookie helps mitigate the risk of client side script accessing the protected cookie (if the browser supports it). (https://www.owasp.org/index.php/HttpOnly)

CookieJS.set({name: '', value: '', expires: '', path: '', domain: '', secure: true/false, httpOnly: true/false});

CookieJS.set({
        name: 'mycookie',
        value:'myvalue',
        expires: 30, // x Days
        path: '/', // Website path
        domain: 'domain.com', // Optional
        secure: true, // Optional
        httpOnly: false // Optional
});

No return value.


CookieJS.get(name);

CookieJS.get('mycookie');

Returns the value of the stored cookie, or undefined if the cookies key does not exist.


CookieJS.getAll(void); Return all cookies.

//Example:
var cookies = CookieJS.getAll();
console.log(cookies.mycookie);
// Output: myvalue

Returns a key-value hash of available cookies on the document. If there are no available cookies, an empty hash is returned.


CookieJS.keys(void); Return all cookie keys.

//Example:
var cookies = CookieJS.keys();
console.log(cookies[0]);
// Output: mycookie

Returns an array of keys of set cookies. If no cookies have been set, CookieJS.keys() returns an empty array.

CookieJS.has(name);

CookieJS.has('mycookie');
//Output: returns true or false

Returns true if name is the key of a cookie, otherwise returns false.


CookieJS.delete({name: '', path: '', domain: ''});

CookieJS.delete({
        name: 'mycookie',
        path: '/'
});

No return value.