secure_session 1.0.5 copy "secure_session: ^1.0.5" to clipboard
secure_session: ^1.0.5 copied to clipboard

Secure stateless cookie session for Dart. It is a simple and secure way to manage user sessions in web applications.

example/lib/example.dart

import 'dart:io';

import 'package:secure_session/secure_session.dart';

Future<void> main(List<String> arguments) async {
  final server = await HttpServer.bind(InternetAddress.anyIPv4, 8080);
  print('Listening on localhost:${server.port}');

  await for (HttpRequest request in server) {
    final secureSession = SecureSession(options: [
      SessionOptions(
        cookieName: 'session',
        defaultSessionName: 'session',
        expiry: const Duration(days: 1),
        keyPath: 'example/assets/rsa_key.pem',
        separator: r';',
        secret: 'my secret',
        cookieOptions: CookieOptions(),
        salt: 'salt',
      ),
    ]);
    secureSession.init(request.cookies);
    secureSession.write('John Doe', 'session');
    request.response.write(secureSession.read('session'));
    await request.response.close();
  }
}
0
likes
160
pub points
12%
popularity

Publisher

verified publisherserinus.app

Secure stateless cookie session for Dart. It is a simple and secure way to manage user sessions in web applications.

Repository (GitHub)
View/report issues

Topics

#secure #session #http #server

Documentation

API reference

License

MIT (license)

Dependencies

crypto, encrypt

More

Packages that depend on secure_session