GithubHelp home page GithubHelp logo

myconsciousness / sweet-cookie-jar Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 4.0 31 KB

A most easily usable cookie management library in Dart. With SweetCookieJar, you can easily manage cookie on your application.

Home Page: https://pub.dev/packages/sweet_cookie_jar

License: BSD 3-Clause "New" or "Revised" License

Dart 100.00%
dart flutter cookie cookiejar library pubdev cookie-management

sweet-cookie-jar's Introduction

sweet_cookie_jar

A most easily usable cookie management library in Dart!

pub package codecov Analyzer Test

1. About

SweetCookieJar is an open-sourced Dart library.
With SweetCookieJar, you can easily manage cookie on your application.

SweetCookieJar is a library that extends the functionality of the official Cookie class. It also works with Responses in the http package, and even if multiple set-cookie are set in the response header, which is a weak point in the http package, SweetCookieJar can manage these cookie information very easily!

No more difficult implementation is needed to handle multiple set-cookie set in response header in Dart. Just pass the Response to the constructor of SweetCookieJar!

1.1. Introduction

1.1.1. Install Library

With Dart:

 dart pub add sweet_cookie_jar

With Flutter:

 flutter pub add sweet_cookie_jar

1.1.2. Import It

import 'package:sweet_cookie_jar/sweet_cookie_jar.dart';

1.1.3. Use SweetCookieJar

import 'package:sweet_cookie_jar/sweet_cookie_jar.dart';

void main() {
    // The cookie set in the response header
    // will be extracted by the constructor process.
    final cookieJar = SweetCookieJar.from(response: response);

    if (cookieJar.isEmpty) {
        // It means that there is no cookie information
        // in the response header.
        return;
    }

    // You can find cookie by name easily.
    final cookie = cookieJar.find(name: 'AWSALB');
    print(cookie.name);
    print(cookie.value);

    // Also you can get cookie as JSON format.
    print(cookie.toJson());

    if (cookie.isExpired) {
        // Do something when cookie is expired.
        return;
    }
}

1.2. License

Copyright (c) 2021, Kato Shinya. All rights reserved.
Use of this source code is governed by a
BSD-style license that can be found in the LICENSE file.

1.3. More Information

SweetCookieJar was designed and implemented by Kato Shinya.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.