Local Storage & Cookie

View previous topic View next topic Go down

Local Storage & Cookie

Post by Scarlet on Mon Apr 27, 2015 6:03 pm

In this thread, I'll show you the Local Storage & the Cookie object.
First thing first, let's take a peek to this code.

Code:
var username = 'Carol';
var password = 'carol123';
var inp = document.getElementsByName('username');
var inp2 = document.getElementsByName('password');
if(inp !== username) { alert('Username do not match'); }
if (inp2 !== password) { alert('password do not match'); }

It must be extra insecure to keep the username and the password both in a variable. Hackers can also hack with this if they know what they're doing and if they know how to work with variables. They can also try typing 'username' in Web Console and 'password' in Web Console and bam, they get the results.

So, what is exactly a cookie are? A cookie was an object (if I didn't mistaken) that keeps certain data. Like how many times the visitor visits the webpage, and many more.
And also, what is exactly a local storage are? A local storage was an object that also keeps certain data, but is more faster and more secure, that's what Google says when I looked up some websites.
But, hey, even if the Google says 'more faster and more secure', that doesn't mean you can store sensitive information to the local storage. Those 'black hat' or 'gray hat' can get the values in the local storage, because there's a getItem method available in local storage. It's as simple as this! :

Code:
localStorage.getItem(key);

Something like that might work, if the hacker knows how to work with local storages. So they can access your information up with a simple type! Isn't that creepy.

(do Google 'local storage more secure' for more info)

So, you must only store non-personal data into both cookie and both local storage. Why, because you can't. If you store a personal data in the cookie nor in the local storage, that means you're allowing peoples to 'hack' your data! And even manipulate them remotely (if they know how to)! Be careful with data(s) you're stored in, if you'll store important data, like, passwords to automatically fill the form, just no, don't. Every browsers (if I didn't mistaken) had this option so it's completely unnecessary to do that in such a place, except for a browser that didn't uses Autofill.

avatar
Scarlet
Admin

Member Title : Classy Person
Posts : 28
Join date : 2015-04-16

View user profile http://codingsupport.topicboards.com

Back to top Go down

Re: Local Storage & Cookie

Post by Kurome on Sat Aug 01, 2015 2:34 pm

Cookie

In Forumotion we have our own cookie that simplifies cookie making.

Syntax:
Code:
my_setcookie([name],[expires],[value],[path]);
my_getcookie([name]);

Parameters:
name - name of cookie.
expires - the date the cookie expires.
value - the value of cookie.
path - the path of cookie.

Example of usage is this.

Code:
my_setcookie('mytest','foo');

Now what just happened? We just set a cookie.
And if you want to know what happened just type this.

Code:
my_getcookie('mytest');

It might returns 'foo'.
So just like what Scarlet explained, a cookie is an object that contains a data. An example is a.. container. Or a storage.

Oh, and what if we want to store a data inside a variable?
That's just simple.

Code:
var mytest = 'This is test.';
my_setcookie('testing',mytest);

Don't wrap the variable name with a quote; single quote, double quote, don't--just don't. If you wrap it, it might read the variable name as a string.

That's what I'll explain in this post.

Kurome

Member Title : Member
Posts : 3
Join date : 2015-04-19

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum