問題描述
我正在創(chuàng)建 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 或任何其他基于令牌身份驗證的工具/庫,因此只需保存該令牌,當窗口加載時,您將檢查令牌是否存在且仍然有效,如果是,您可以重定向用戶轉(zhuǎn)到所需頁面或讓他導航,邏輯取決于您,但這是您擁有的兩個選項.
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 數(shù)據(jù)庫嗎的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!