---
title: "Discussion on \"How to Save User's Data Persistently in Web Browser Using Local Storage\" | Hashnode"
description: "Discussion on \"How to Save User's Data Persistently in Web Browser Using Local Storage\". LocalStorage is a property of windows object, it allows us to store key-value pairs in a web browser.\nThe localStorage's data has no expiration date."
url: "https://hashnode.com/posts/local-storage-in-javascript/616fdd000c5e175a1c610c54"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How to Save User's Data Persistently in Web Browser Using Local Storage](https://blog.yuvraj.tech/local-storage-in-javascript?utm_source=hashnode&utm_medium=feed)

LocalStorage is a property of windows object, it allows us to store key-value pairs in a web browser. The localStorage's data has no expiration date.

Oct 20, 2021 · 4 min read · blog.yuvraj.tech  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#es6](https://hashnode.com/tag/es6)
-   [#web-development](https://hashnode.com/tag/web-development)

## Written by

[Yuvraj Singh Jadon](https://hashnode.com/@yuvraajsj18)

@yuvraajsj18 · New Delhi, India

  
[View profile](https://hashnode.com/@yuvraajsj18)

Computer Science Student

Hello! I'm Yuvraj. I'm a Computer Science Student. I love to learn, create, and explore new things. I am currently doing a Bachelor of Computer Science from the University of Delhi.

## Responses 1

Markdown supported · ⌘↵ to post

[Apoorv Tyagi](https://hashnode.com/@apoorvtyagi)

[Oct 20, 2021](https://hashnode.com/posts/local-storage-in-javascript/616fdd000c5e175a1c610c54/comment/617009c3d78c655a23127ff6)

Is it possible if I get someone's auth token from their local storage and add it to my browser's local storage? Will that token work for me? For example, If I store the login token for each user in the local storage but let's say someone got access to that token, can they then login using that token from their own browser?

Basically, how does the browser ensures the security of data?

[Yuvraj Singh Jadon](https://hashnode.com/@yuvraajsj18)

[Oct 20, 2021](https://hashnode.com/posts/local-storage-in-javascript/616fdd000c5e175a1c610c54/comment/617009c3d78c655a23127ff6#reply-61705be90c5e175a1c6118ef)

Yes, once a token is stolen the account would be compromised. That's why sensitive information must never be stored in local storage as browser doesn't ensure any security. Any third party js code used on the website can access local storage thus increasing the chances of token theft.

Will also update the article to include this point. Thanks for pointing it out. 🙌🙌

Also [developer.okta.com/blog/2018/06/20/what-happens-i…](https://developer.okta.com/blog/2018/06/20/what-happens-if-your-jwt-is-stolen) this is a brilliant article about the same. Worth a read.

[Apoorv Tyagi](https://hashnode.com/@apoorvtyagi)

[Oct 24, 2021](https://hashnode.com/posts/local-storage-in-javascript/616fdd000c5e175a1c610c54/comment/617009c3d78c655a23127ff6#reply-6175901c0f452c1cd94fb8be)

[Yuvraj Singh Jadon](https://hashnode.com/@yuvraajsj18) Thanks for the answer.
