Socket
Book a DemoInstallSign in
Socket

aurelia-plugins-cookies

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aurelia-plugins-cookies

A cookies plugin for Aurelia.

2.6.0
latest
Source
npmnpm
Version published
Weekly downloads
1.3K
27.43%
Maintainers
1
Weekly downloads
 
Created
Source

aurelia-plugins-cookies

A cookies plugin for Aurelia.

Installation

Webpack/Aurelia CLI

npm install aurelia-plugins-cookies --save

When using Aurelia CLI add the following dependency to aurelia.json:

{
  "name": "aurelia-plugins-cookies",
  "path": "../node_modules/aurelia-plugins-cookies/dist/amd",
  "main": "aurelia-plugins-cookies"
}

Add node_modules/babel-polyfill/dist/polyfill.min.js to the prepend list in aurelia.json. Do not forgot to add babel-polyfill to the dependencies in package.json.

JSPM

jspm install aurelia-plugins-cookies

Bower

bower install aurelia-plugins-cookies

Configuration

It is not necessary to load the plugin inside of the configure method of your main.js or main.ts, because this plugin doesn't use any dependencies of Aurelia. The only thing you need to be sure of, is that the library is loaded in your project.

Usage

The plugin is used as a class with static methods. No dependency injection is necessary. Just import it in your own class.

The following methods are provided:

import {Cookies} from 'aurelia-plugins-cookies';

export class App {
  // Returns the value (string) of the given cookie key
  Cookies.get(key);
  
  // Returns a key/value object with all the cookies
  Cookies.getAll();
  
  // Returns the deserialized value (object) of the given cookie key
  Cookies.getObject(key);

  // Sets a value (string) for the given cookie key
  Cookies.put(key, value, [options]);
  
  // Sets a serialized value (object) for the given cookie key
  Cookies.putObject(key, value, [options]);
  
  // Remove the cookie with the given cookie key
  Cookies.remove(key, [options]);
  
  // Removes all the cookies
  Cookies.removeAll();
}

Options

Cookie options can be set by passing a plain object in the last argument to Cookies.put(...).

domain

A string indicating a valid domain where the cookie should be visible. The cookie will also be visible to all subdomains.

Cookies.put('key', 'value', { domain: 'subdomain.site.com' });

expires

Define when the cookie will be removed. Value can be a string which will be converted to a date or a Date instance. If omitted, the cookie becomes a session cookie.

Cookies.put('key', 'value', { expires: 'Fri, 09 Sep 2016 00:00:01 GMT' });

path

A string indicating the path where the cookie is visible.

Cookies.put('key', 'value', { path: '/' });

secure

Either true or false, indicating if the cookie transmission requires a secure protocol (https).

Cookies.put('key', 'value', { secure: true });

Keywords

aurelia

FAQs

Package last updated on 17 Apr 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.