New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cookie-micro

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cookie-micro

JavaScript Cookie micro library

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

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.


//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.

Keywords

FAQs

Package last updated on 19 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc