 // 设置cookie
const setCookie = (name, value, day) => {
  var date = new Date();
  date.setDate(date.getDate() + day);
  document.cookie = name + "=" + value + ";expires=" + date;
}

// 获取cookie
const getCookie = (name) => {
  var reg = RegExp(name + "=([^;]+)");
  var arr = document.cookie.match(reg);
  if (arr) {
    return arr[1];
  } else {
    return "";
  }
}

// 记录登录用户和密码赋值
export const isRememberLogin = () => {
  return {
    loginName: getCookie('username'),
    password: getCookie('password'),
    isRemPass: getCookie('isRemPass')
  }
};

// 记住密码设置
export const rememberLogin = (username, password, keeplogin, day) => {
  setCookie('isRemPass', keeplogin, day );
  setCookie('username', username, day );
  setCookie('password', password, day );
}



