LocalStorageSessionStorage | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

LocalStorageSessionStorage

Can someone give me a better explanation of local and session storage is there an example code that i can see??

6th Jul 2017, 7:23 PM
_Legend27_
_Legend27_ - avatar
12 Answers
+ 1
Think of localStorage in the same way that you think of cookies. It's data stored on your end and can persist between sessions. Whereas a session is only for that session and is gone when you close the page. Personally, I don't recommend storing your password or any critical data in either. However, you can certainly store an ID that's given to the user after they log in, or something like that. Keep your passwords / personal data stored in database and make sure pass is encrypted. When you go to log in, have your server-side scripting check inputted password against the database, and if its correct, return the other data to set up the session for logged in user. You can have it create and set a unique key in the database for the user when it's confirmed they used correct password; that'll help keep people from being able to spoof the ID for a particular user.
6th Jul 2017, 7:35 PM
AgentSmith
7th Jul 2017, 2:23 AM
Benneth Yankey
Benneth Yankey - avatar
+ 2
lolol Nice username. :D Just noticed it. Anyways, localStorage lets you save data and retrieve it. It stays until you delete it. The sessionStorage is going to store it for that WINDOW until the window is no longer in existence (you close it). Hope that helps.
6th Jul 2017, 7:26 PM
AgentSmith
+ 2
haha thxs anyways is this used to save passwords and emails that people input into the website.if so..how do you see the info after??
6th Jul 2017, 7:28 PM
_Legend27_
_Legend27_ - avatar
+ 2
Have you learned any server-side programming langs (PHP/ASP/Node) and SQL yet? If not, go read those and it'll start making more sense. lol
6th Jul 2017, 7:39 PM
AgentSmith
+ 2
im learning html5 thats why..
6th Jul 2017, 7:40 PM
_Legend27_
_Legend27_ - avatar
+ 2
Gotcha. HTML best place to start with it all. :) Just take note of it in your head for now, and keep pushing through HTML. When you're done with HTML, I'd recommend reading through CSS3 and JavaScript next. Then read one of the JS frameworks, such as jQuery or AngularJS. Then learn PHP and MySQL. By that point, it'll all make sense to ya. It doesn't take as long as it sounds to learn all of that. lol Best of luck to you bro!
6th Jul 2017, 7:43 PM
AgentSmith
+ 2
You're more than welcome bro. Don't hesitate to post up any questions you have. I'm not the best person to explain things, but there are a lot of amazing people here willing to help out.
6th Jul 2017, 7:44 PM
AgentSmith
+ 1
wow......im confused
6th Jul 2017, 7:36 PM
_Legend27_
_Legend27_ - avatar
+ 1
i dont wanna bug you but.....
6th Jul 2017, 7:37 PM
_Legend27_
_Legend27_ - avatar
+ 1
thxs
6th Jul 2017, 7:44 PM
_Legend27_
_Legend27_ - avatar
+ 1
k
6th Jul 2017, 7:45 PM
_Legend27_
_Legend27_ - avatar