Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General > HTML / DHTML

Notices


Reply
 
Thread Tools Rate Thread Display Modes
Old 04-20-2016, 05:24 AM   #1
sarvodyaseo
Registered User
 
Join Date: Mar 2014
Posts: 86
What is the difference between local storage and cookies?

Hello friends i want to know What is the difference between local storage and cookies?
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
sarvodyaseo is offline   Reply With Quote

Old 04-29-2016, 12:20 AM   #2
krify
Registered User
 
Join Date: Feb 2016
Posts: 83
[B]Cookies[/B

Pros:
Legacy support (it's been around forever)
Persistent data
Expiration dates

Cons

Each domain stores all its cookies in a single string, which can make parsing data difficult
Data is unencrypted, which becomes an issue because...... though small in size, cookies are sent with every HTTP request
Limited size (4KB)
SQL injection can be performed from a cookie

Local storage

Pros

Support by most modern browsers
Persistent data that is...... stored directly in the browser
Same-origin rules apply to local storage data
Is not sent with every HTTP request
~5MB storage per domain (that's 5120KB)

Cons

Not supported by anything before:
IE 8
Firefox 3.5
Safari 4
Chrome 4
Opera 10.5
iOS 2.0
Android 2.0
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
KRIFY DOT CO
krify is offline   Reply With Quote
Old 05-05-2016, 04:22 AM   #3
wiliam1995
Registered User
 
Join Date: Jan 2016
Posts: 227
Cookies and local storage serve different purposes. Cookies are primarily for reading server-side, local storage can only be read client-side. So the question is, in your app, who needs this data — the client or the server?

If it's your client (your JavaScript), then by all means switch. You're wasting bandwidth by sending all the data in each HTTP header.

If it's your server, local storage isn't so useful because you'd have to forward the data along somehow (with Ajax or hidden form fields or something). This might be okay if the server only needs a small subset of the total data for each request.

You'll want to leave your session cookie as a cookie either way though.

As per the technical difference, and also my understanding:

Apart from being an old way of saving data, Cookies give you a limit of 4096 bytes (4095, actually) - its per cookie. Local Storage is as big as 5MB per domain - SO Question also mentions it
localStorage is an implementation of the Storage Interface. It stores data with no expiration date, and gets cleared only through JavaScript, or clearing the Browser Cache / Locally Stored Data - unlike cookie expiry.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
||
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
||
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
||
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
||
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
||
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wiliam1995 is offline   Reply With Quote
Old 07-01-2016, 12:28 AM   #4
Kiara
Registered User
 
Join Date: Jun 2016
Location: USA
Posts: 55
Local storage:
1. Local storage stores the data in the form of key and value
2. The data is stored for longer duration and remains in the browser unless the user deletes it explicitly, it remains even after a computer restart.
3. No way to specify the timeout period as the Cookies have.
4. Good to create an offline application that runs on the client machine (browser).
5. Easy to work with the JavaScript.
6. Local storage data is not sent to the server on every request (HTTP header) as it is purely at the client side.
Cookies :
1. Good for small amount of data
2. Difficult to work with JavaScript
3. All data is transferred to and from server, so bandwidth is consumed on every request
4. Can specify timeout period so that cookies data are removed from browser
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Kiara is offline   Reply With Quote
Old 07-14-2016, 12:18 AM   #5
rekhaweb
Registered User
 
Join Date: Jul 2016
Posts: 28
Local storage

- Local storage stores the data in the form of key and value
- The data is stored for longer duration and remains in the browser unless user delete it explicitly, it remains even after computer restart
- No way to specify the time out period as the Cookies have
- Good to store large amount of data, up to 4MB

Cookies

- Good for small amount of data
- Difficult to work with JavaScript
- All data is transferred to and from server, so bandwidth is consumed on every request
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
rekhaweb is offline   Reply With Quote
Old 07-22-2016, 06:33 AM   #6
sashwatmegh
Registered User
 
Join Date: Apr 2016
Location: pune
Posts: 583
Local storage is good to create an offline application that runs on the client machine.
Cookies are good for small amount of data and tough to work with JavaScript.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
sashwatmegh is offline   Reply With Quote
Old 08-07-2016, 10:44 AM   #7
iqbaljan
Registered User
 
Join Date: Aug 2016
Posts: 20
Cookies are primarily for reading server-side, localStorage can only be read client-side.
Cookies allow you to store string only while using local storage you can store JavaScript but not object or array.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
iqbaljan is offline   Reply With Quote
Old 08-09-2016, 12:10 AM   #8
uStoreharddisk
Registered User
 
Join Date: Jul 2016
Location: hong kong
Posts: 49
local storage stores large amount of data and cookies stores small amount of data
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
uStoreharddisk is offline   Reply With Quote
Old 09-05-2016, 11:17 PM   #9
eumaxindia
Registered User
 
Join Date: Aug 2016
Posts: 640
Cookies data store temporarily and local stroage data store user can delete the information itself...
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
eumaxindia is offline   Reply With Quote
Old 09-22-2016, 01:46 AM   #10
kunalkumar
Registered User
 
Join Date: Apr 2016
Posts: 198
Local storage:
1. Local storage stores the data in the form of key and value
2. The data is stored for longer duration and remains in the browser unless the user deletes it explicitly, it remains even after a computer restart.
3. No way to specify the timeout period as the Cookies have.

Cookies :
1. Good for small amount of data
2. Difficult to work with JavaScript
3. All data is transferred to and from server, so bandwidth is consumed on every request
4. Can specify timeout period so that cookies data are removed from browser
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by kunalkumar; 10-13-2016 at 02:23 AM..
kunalkumar is offline   Reply With Quote
Old 10-01-2016, 02:51 AM   #11
whmcssmarters
Registered User
 
Join Date: Sep 2016
Posts: 85
Quote:
Originally Posted by rekhaweb View Post
Local storage

- Local storage stores the data in the form of key and value
- The data is stored for longer duration and remains in the browser unless user delete it explicitly, it remains even after computer restart
- No way to specify the time out period as the Cookies have
- Good to store large amount of data, up to 4MB

Cookies

- Good for small amount of data
- Difficult to work with JavaScript
- All data is transferred to and from server, so bandwidth is consumed on every request

Hi, very important information thanks for sharing.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.



To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.



To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
whmcssmarters is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:09 AM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.