1.0.6 • Published 6 months ago

@caviajs/http-cookie v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Introduction

An HTTP cookie is a small piece of data stored by the user's browser. Cookies were designed to be a reliable mechanism for websites to remember stateful information. When the user visits the website again, the cookie is automatically sent with the request.

Usage

Installation

npm install @caviajs/http-cookie --save

Request cookies

Parse cookies

import { HttpCookie } from '@caviajs/http-cookie';

router
  .route({
    handler: (request, response, next) => {
      const cookies = HttpCookie.parse(request);
      
      // cookies...
    },
    /* ... */
  });

Response cookies

Set cookie

import { HttpCookie } from '@caviajs/http-cookie';

router
  .route({
    handler: (request, response, next) => {
      HttpCookie.set(response, 'name', 'value', {
        /* 
          domain?: string;
          expires?: Date;
          httpOnly?: boolean;
          maxAge?: number;
          path?: string;
          sameSite?: 'Lax' | 'Strict' | 'None';
          secure?: boolean; 
        */
      });
    },
    /* ... */
  });

Delete cookie

import { HttpCookie } from '@caviajs/http-cookie';

router
  .route({
    handler: (request, response, next) => {
      HttpCookie.delete(response, 'name', {
        /* 
          domain?: string;
          httpOnly?: boolean;
          path?: string;
          sameSite?: 'Lax' | 'Strict' | 'None';
          secure?: boolean; 
        */
      });
    },
    /* ... */
  });
1.0.6

6 months ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

1.0.3

1 year ago

0.2.1

2 years ago

0.2.2

2 years ago

0.2.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago