nhuluseda
nhuluseda

Reputation: 777

How to use session user in flutter?

I've been trying to make user login and register with http in flutter using dart. Somehow i want to make user stay at the app using session or cookie. Anyone have been trying it yet?

Upvotes: 10

Views: 27393

Answers (2)

Jhourlad Estrella
Jhourlad Estrella

Reputation: 3670

If you are looking for a user session instead of HTTP session, check out flutter_session.

It's really easy to implement and persists through pages even after navigating.

Upvotes: 2

Jossef Harush Kadouri
Jossef Harush Kadouri

Reputation: 34237

Check out requests

  • as of now, it uses shared_preferences which is not the best practice (security-wise) to store sensitive data (session-ids etc) Issue #1

pubspec.yaml

dependencies:
  requests: ^1.0.0

Usage:

import 'package:requests/requests.dart';

// ...

// this will persist cookies
await Requests.post("https://example.com/api/v1/login", body: {"username":"...", "password":"..."} ); 

// this will re-use the persisted cookies
dynamic data = await Requests.get("https://example.com/api/v1/stuff", json: true); 

Upvotes: 3

Related Questions