• Problems

    This line enable URL Rewriting . It must be enabled via the RewriteEngine directive! and if your .htaccess file is going to use rewrite rules, you should always include this line. Otherwise, you can’t be sure if its enabled or not. The string “on” is case insensitive.

The Web Storage API defines a standard for how we can save simple data locally
on a user’s computer or device. Before the emergence of the Web Storage standard,
web developers often stored user information in cookies, or by using plugins. With
Web Storage, we now have a standardized definition for how to store up to 5MB of
simple data created by our websites or web applications. Better still, Web Storage
already works in Internet Explorer 8.0!
Web Storage is a great complement to Offline Web Applications, because you need
somewhere to store all that user data while you’re working offline, andWeb Storage
provides it.
Web Storage is supported in these browsers:
¦ Safari 4+
¦ Chrome 5+
¦ Firefox 3.6+
¦ Internet Explorer 8+
¦ Opera 10.5+
¦ iOS (Mobile Safari) 3.2+
¦ Android 2.1+

Website data can be saved in user computer in various way :
1)session storage
2)cookies storage
3)local storage

Now we are going to use local storage for our purpose:
Unlike session storage, local storage allows us to save persistent data to the user’s
computer, via the browser. When a user revisits a site at a later date, any data saved
to local storage can be retrieved.

Local Storage versus Cookies
Local storage can at first glance seem to play a similar role to HTTP cookies, but
there are a few key differences. First of all, cookies are intended to be read on the
server side, whereas local storage is only available on the client side. If you need
your server-side code to react differently based on some saved values, cookies are
the way to go. Yet, cookies are sent along with each HTTP request to your server
—and this can result in significant overhead in terms of bandwidth. Local storage,
on the other hand, just sits on the user’s hard drive waiting to be read, so it costs
nothing to use.
In addition, we have significantly more size to store things using local storage.
With cookies, we could only store 4KB of information in total.With local storage,
the maximum is 5MB.

What Web Storage Data Looks Like
Data saved in Web Storage is stored as key/value pairs.
A few examples of simple key/value pairs:
¦ key: , value:
¦ key: , value:
¦ key: , value:

Step for using local storage :
Step one :Storing data
Step two: Retriving store data

STEP ONE :STORING DATA: Data can be stored in local storage by using setItem in the following way-

localStorage.setItem("size", "6");

This store 6 value to the key size.And instead of localStorage.setItem(key, value), we can say localStorage[key]
= value:

localStorage["size"] = 6;

STEP TWO:RETRIVING DATA:-Data can be retrive from  local storage by using getItem in the following way-

var size = localStorage.getItem("size");

Instead of localStorage.getItem(key), we can simply say localStorage[key].
For example
var size = localStorage["size"];

No comments:

Post a Comment