[Flutter Web] 쿠키 및 세션 관리 (cookie And Session Management)

localStorage : 로컬스토리지 (쿠키)
sessionStorage : 세션
Map 형식 값 저장 및 불러오기

import 'package:flutter/material.dart';
import 'package:universal_html/html.dart';

class WebStorage {

  static Storage sessionStorage = window.sessionStorage;
  static Storage localStorage = window.localStorage;

  static String sessionGetValue({
    @required String key
  }){
    return sessionStorage[key];
  }

  static void sessionSetValue({
    @required String key,
    @required String value,
  }){
    sessionStorage[key] = value;
  }
  static String localGetValue({
    @required String key
  }){
    return localStorage[key];
  }

  static void localSetValue({
    @required String key,
    @required String value,
  }){
    localStorage[key] = value;
  }
}

답글 남기기

이메일 주소는 공개되지 않습니다.