can we use SQLite database in PWA app(我们可以在 PWA 应用程序中使用 SQLite 数据库吗)
问题描述
我正在创建 Progressive-web-app 应用程序,我想将用户信息存储在本地设备中.那么,我该怎么做.如何存储用户登录信息,以便他不必一次又一次地登录
I am creating Progressive-web-app application ,I want to store user information in local device. So, how can i do this.how can I store user login information,so that he does not have to login again and again
推荐答案
浏览器没有 SQLite,你可以使用 IndexedDB 或 localStorage.
There's no SQLite for browsers, the closer you can achieve is using IndexedDB or localStorage.
我假设您正在使用 JWT 或任何其他基于令牌身份验证的工具/库,因此只需保存该令牌,当窗口加载时,您将检查令牌是否存在且仍然有效,如果是,您可以重定向用户转到所需页面或让他导航,逻辑取决于您,但这是您拥有的两个选项.
I'm assuming you're using JWT or any other token authentication based tool/library, so just save that token and when the window load you'll check if the token is present and still valid, if so you can redirect the user to a desired page or let him navigate, the logic is up to you, but these are the two options you have.
希望这会有所帮助.
这篇关于我们可以在 PWA 应用程序中使用 SQLite 数据库吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我们可以在 PWA 应用程序中使用 SQLite 数据库吗
基础教程推荐
- 带有WHERE子句的LAG()函数 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
