HTTP cookie (also known as a web cookie, or browser cookie) is used for an origin website to send state information to a user’s browser and for the browser to return the state information to the origin site. Source: Wikepedia
Cookies have serveral drawback for developers:
- Security – Cookies are stored in plain text on the user’s hard drive so there is a good chance that they could be hacked
- Performance – every HTTP request/response between server and browser obviously affects the speed
- Size Limit – Generally cookies are limited to 4096 bytes and 300 cookies per one domain
HTML5 Web Storage
Due to the drawbacks mentioned above with cookies, developers have started seeking for a new and efficient solution. Currently this solution is HTML5 web storage is the answer and based on the increased popularity of HTML5 as a whole I think we will only see the web storage improve.
THe 2 key features that trump cookies are:
- Large Storage – You can store hefty amounts of data on the user’s hard drive including some localization data and temprorary storage
- Simple API – very easy to set up key/value pairs on the fly
Local Storage uses a similar technology to that of Silverlight isolated storage when all data is stored on the client side. Local storage has no time limit so you can access them any time you want without the worry of expiration.
Session storage is used to store data about one session and is removed as soon as the user closes the browser window. THis is great for storing data aobut a website that uses one widow where local storage can span across multiple windows.
Web storageis supported by most newer browsers including IE8+, Firefox 3.5+, Safari 4+, Google Chrome 4+, Opera 10.5+. Be mindful of the lack of support on the older browsers.
Web Storage Usage
This technology is great for developers that create various web applications and local storage allows you to run applications offline, use data during multiple sessions, save info about the products added to a cart and so on. As with cookies, web storage can be turned off on the browser so its best to not rely 100% on its usage.
Amortech is a Calgary Web Development company that specializes in HTML5 web usage. We are constantly evolving with the technology so that your website meets or exceeds all expectations for you, your visitors and most importantly – the web browser.