shelf_simple_session 0.1.3

shelf_simple_session #

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

Use this package as a library

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

Alternatively, your editor might support pub 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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.5.0 <2.0.0