Cookie

Simple cookies manipulation (browser side) with api similar to jquery.cookie

Example

import 'package:cookie/cookie.dart' as cookie;

Create session cookie:

cookie.set('the_cookie', 'the_value');

Create expiring cookie, 7 days from then:

    cookie.set('the_cookie', 'the_value', expires: 7);

Create expiring cookie, valid across entire site:

    cookie.set('the_cookie', 'the_value', expires: 7, path: '/');

Read cookie:

    cookie.get('the_cookie'); // => "the_value"
    cookie.get('not_existing'); // => null

Delete cookie:

    // Same path as when the cookie was written...
    cookie.remove('the_cookie', path: '/');

Note: when deleting a cookie, you must pass the exact same path, domain and secure options that were used to set the cookie, unless you're relying on the default options that is.

Libraries