Biskviit HTTP Cookie Handler

2.0.0 · abandoned · verified Wed Apr 22

Biskviit is a Node.js module designed for server-side HTTP cookie management. It provides functionality to parse `Set-Cookie` headers from incoming responses, store cookie data in memory, and then generate appropriate `Cookie` headers for outgoing requests based on a specified URL. The current stable version is 2.0.0, which was last updated in August 2017. Due to its age, the package is considered to have an abandoned release cadence. Its key differentiator is its straightforward, in-memory approach to handling cookie state per instance, including basic session timeout management for cookies without explicit expiration dates. It is specifically built for Node.js environments and requires Node.js v6 or higher.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates initializing a Biskviit instance, setting cookies from `Set-Cookie` headers, and retrieving them for specific URLs both as a header string and as an array of objects.

const Biskviit = require('biskviit');

// Create a cookie managing instance with a 5-minute session timeout
const biskviit = new Biskviit({
    sessionTimeout: 5 * 60 // expire cookies after 5 minutes
});

// Simulate setting cookies from a 'Set-Cookie' header
biskviit.set('theme=light', 'http://example.com/');
biskviit.set('sessionToken=abc123; Expires=Wed, 09 Jun 2029 10:18:14 GMT; Path=/', 'http://example.com/');
biskviit.set('another=cookie; Max-Age=3600', 'https://secure.example.com/app');

// Get cookies for a specific URL as a string for the 'Cookie' header
const cookiesForExample = biskviit.get('http://example.com/path');
console.log('Cookies for example.com:', cookiesForExample); // Expected: theme=light; sessionToken=abc123

const cookiesForSecureExample = biskviit.get('https://secure.example.com/app/dashboard');
console.log('Cookies for secure.example.com:', cookiesForSecureExample); // Expected: another=cookie

// List all available cookies for a URL as objects
const cookieObjects = biskviit.list('http://example.com/');
console.log('Cookie objects for example.com:', cookieObjects);

view raw JSON →