shelf_simple_session 0.1.3

  • Installing
  • Versions
  • 42


A very simple cookie based session handler for dart Shelf middleware.

Here is an example of usage (see example/session_example.dart)

    // simple handler that increments a counter stored in the session
      shelf.Response pingHandler(shelf.Request request) {
        // session() function gets a reference to the session map
        var map = session(request);
        var c = map['counter'];
        int counter = ( c == null ? 0 : c) +1;
        //store counter in the session
        map['counter'] = counter;
        return new shelf.Response.ok("ping counter=$counter");
      var handler = const shelf.Pipeline()
          .addMiddleware(sessionMiddleware(new SimpleSessionStore()))
      // listen on port 7001
      io.serve(handler, InternetAddress.ANY_IP_V4, 7001);


This is super simple, and there are lots of enhancements that should be made:

  • The session maintenance / timeout code is not efficient
  • This wont work in a multi-isolate environment (needs some of way of sharing session data between isolates)
  • When Shelf gets proper cookie handling, the cookie code in here should be replaced
  • Tests. Could use some
  • Implement session data encryption

1. Depend on it

Add this to your package's pubspec.yaml file:

  shelf_simple_session: "^0.1.3"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:shelf_simple_session/shelf_simple_session.dart';
Version Uploaded Documentation Archive
0.1.3 Dec 8, 2016 Go to the documentation of shelf_simple_session 0.1.3 Download shelf_simple_session 0.1.3 archive
0.1.2 Oct 10, 2014 Go to the documentation of shelf_simple_session 0.1.2 Download shelf_simple_session 0.1.2 archive
0.1.1 Oct 9, 2014 Go to the documentation of shelf_simple_session 0.1.1 Download shelf_simple_session 0.1.1 archive
0.1.0 Oct 9, 2014 Go to the documentation of shelf_simple_session 0.1.0 Download shelf_simple_session 0.1.0 archive


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
95 / 100
Reflects how tidy and up-to-date the package is. [more]
67 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: Flutter, other

Primary library: package:shelf_simple_session/shelf_simple_session.dart with components: io.


  • Maintain

    Changelog entries help clients to follow the progress in your code.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use shelf_simple_session.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.5.0 <2.0.0
crypto >=0.9.0 <1.0.0 0.9.2+1 2.0.2+1
logging >=0.9.1 <1.0.0 0.11.3+1
shelf >=0.5.4 <0.7.0 0.6.8 0.7.2
Transitive dependencies
async 1.13.3 2.0.3
charcode 1.1.1
collection 1.14.5
convert 1.1.1 2.0.1
http_parser 3.1.1
path 1.5.1
source_span 1.4.0
stack_trace 1.9.1
stream_channel 1.6.3
string_scanner 1.0.2
typed_data 1.1.5