我们可以在 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.
希望这会有所帮助.
相关文章