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
can we use SQLite database in PWA app
Asked Answered
Possible duplicate of Local Storage vs Cookies –
Kimberli
set the cookie expire time for longer period like 1 year or 2 year. So that user will be logged out after a longer period which will feel like they are always logged in. And if you are looking for store data like sqllite, you can use indexeddb. check this out article for more help on how tostore data - ujjwalguptaofficial.blogspot.in/2017/10/angular4-crud-operation-in-indexeddb.html –
Organicism
A new interesting way to do this thanks to FileSystemAccesAPIs is to load the SQLite DB from the file system. I've discussed pros and cons here: anita-app.com/blog/articles/… –
Delftware
There's no SQLite for browsers, the closer you can achieve is using IndexedDB or localStorage.
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.
Hope this helps.
Since 2022 there is now an official support (sqlite.wasm), and since 2012 multiple unofficial ones. –
Unprofessional
You can use SQLite in modern WASM-capable browsers thanks to the official sqllite.wasm
:
There is also a persistent storage option via:
- local storage
- session storage
- OPFS (Origin-Private FileSystem)
You can even use it without WebAssembly since 2012.
© 2022 - 2024 — McMap. All rights reserved.