SlideShare una empresa de Scribd logo
1 de 14
Descargar para leer sin conexión
HTML5 localStorage
by yz
function() {
!
var name=
document.getElementById('name').value;
!
!
localStorage.setItem('name', name);!
});
What is local storage?
• data stored in your local computer

=> faster loading :)
• data persists even after you navigate away from the
web site, close your browser tab, exit your browser,
• Cookies and cache are also local storage
review: cache and cookies
• Cache: a temporary storage of web page
resources stored on client’s machine

for quicker loading of the web pages!
• Cookies: a very small piece of information that is
stored on the client’s machine by the web site and
is sent back to the server each time a page is
requested to store information 

for tracking different characteristics related to
user
HTML5 Local Storage
it’s a way for web pages to store named key/value pairs

locally, within the client web browser
Is it different from Cache or
Cookies?
• Cache: speed up loading the page (video, audio,
text messages)
• Cookies: store info about the user
!
• localStorage: store info about the user
to use on the server side
to use on the client side
Is it different from Cache or
Cookies?
• Cookie: user info to be used on the server side
• localStorage: user info to be used on the client
side
function() {
!
var name=
document.getElementById('name').value;
!
!
localStorage.setItem('name', name);!
});
get ‘/’ do
!
@user =
User.find(session[:id])
erb: index
end
Is it different from Cache or
Cookies?
• Cookie: limited to 4 KB of data
• localStorage: 5MG of data
Is it different from Cache or
Cookies?
• Cookie: sent in every HTTP request
• localStorage: not sent in request
How to use localStorage
• Set the key & value pair!
• Retrieve the data!
• Remove the data!
function() {
!
var name=
document.getElementById('name').value;
!
!
localStorage.setItem('name', name);!
});
<input type="name" name="name" id=“name">
Set the key & value pair!
localStorage[“name”] = name
window.onload = function() {
var name = localStorage.getItem('name');
!
if (name != "undefined" || name != "null") {
document.getElementById('welcomeMessage').innerHTML = "Hello " +
name + "!";
} else
document.getElementById('welcomeMessage').innerHTML = "Hello!";
}
}
Retrieve the data!
localStorage[“name”]
localStorage.removeItem('name');
Remove the data!
localStorage.clear();
Summary
• wanna get a lot of user information and use it on
the client side ?

=> use localStorage!
• set, retrieve, remove the data!



localStorage.setItem(“key”,”value”)

localStorage[“key”]


Más contenido relacionado

La actualidad más candente

Displaying message on web page in Javascript
Displaying message on web page in JavascriptDisplaying message on web page in Javascript
Displaying message on web page in JavascriptCodewizacademy
 
Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to JqueryGurpreet singh
 
Building Your First MongoDB App
Building Your First MongoDB AppBuilding Your First MongoDB App
Building Your First MongoDB AppHenrik Ingo
 
Introduction to html & css
Introduction to html & cssIntroduction to html & css
Introduction to html & csssesharao puvvada
 
Geek Sync | Avoid Corruption Nightmares within your Virtual Database
Geek Sync | Avoid Corruption Nightmares within your Virtual DatabaseGeek Sync | Avoid Corruption Nightmares within your Virtual Database
Geek Sync | Avoid Corruption Nightmares within your Virtual DatabaseIDERA Software
 
MongoDB Strange Loop 2009
MongoDB Strange Loop 2009MongoDB Strange Loop 2009
MongoDB Strange Loop 2009Mike Dirolf
 
Magento 2 Seminar - Toon van Dooren - Varnish in Magento 2
Magento 2 Seminar - Toon van Dooren - Varnish in Magento 2Magento 2 Seminar - Toon van Dooren - Varnish in Magento 2
Magento 2 Seminar - Toon van Dooren - Varnish in Magento 2Yireo
 
CouchDB: replicated data store for distributed proxy server
CouchDB: replicated data store for distributed proxy serverCouchDB: replicated data store for distributed proxy server
CouchDB: replicated data store for distributed proxy servertkramar
 
On the incoherencies in web browser access control
On the incoherencies in web browser access controlOn the incoherencies in web browser access control
On the incoherencies in web browser access controlUT, San Antonio
 

La actualidad más candente (10)

Displaying message on web page in Javascript
Displaying message on web page in JavascriptDisplaying message on web page in Javascript
Displaying message on web page in Javascript
 
HTML5
HTML5HTML5
HTML5
 
Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to Jquery
 
Building Your First MongoDB App
Building Your First MongoDB AppBuilding Your First MongoDB App
Building Your First MongoDB App
 
Introduction to html & css
Introduction to html & cssIntroduction to html & css
Introduction to html & css
 
Geek Sync | Avoid Corruption Nightmares within your Virtual Database
Geek Sync | Avoid Corruption Nightmares within your Virtual DatabaseGeek Sync | Avoid Corruption Nightmares within your Virtual Database
Geek Sync | Avoid Corruption Nightmares within your Virtual Database
 
MongoDB Strange Loop 2009
MongoDB Strange Loop 2009MongoDB Strange Loop 2009
MongoDB Strange Loop 2009
 
Magento 2 Seminar - Toon van Dooren - Varnish in Magento 2
Magento 2 Seminar - Toon van Dooren - Varnish in Magento 2Magento 2 Seminar - Toon van Dooren - Varnish in Magento 2
Magento 2 Seminar - Toon van Dooren - Varnish in Magento 2
 
CouchDB: replicated data store for distributed proxy server
CouchDB: replicated data store for distributed proxy serverCouchDB: replicated data store for distributed proxy server
CouchDB: replicated data store for distributed proxy server
 
On the incoherencies in web browser access control
On the incoherencies in web browser access controlOn the incoherencies in web browser access control
On the incoherencies in web browser access control
 

Similar a Lt local storage

Maximize your Cache for No Cash
Maximize your Cache for No CashMaximize your Cache for No Cash
Maximize your Cache for No CashYorick Phoenix
 
PHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONSPHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONSDegu8
 
Module-5_WTA_Managing State & jQuery
Module-5_WTA_Managing State & jQueryModule-5_WTA_Managing State & jQuery
Module-5_WTA_Managing State & jQuerySIVAKUMAR V
 
19_JavaScript - Storage_Cookies_students.pptx
19_JavaScript - Storage_Cookies_students.pptx19_JavaScript - Storage_Cookies_students.pptx
19_JavaScript - Storage_Cookies_students.pptxVatsalJain39
 
19_JavaScript - Storage_Cookies-tutorial .pptx
19_JavaScript - Storage_Cookies-tutorial .pptx19_JavaScript - Storage_Cookies-tutorial .pptx
19_JavaScript - Storage_Cookies-tutorial .pptxssuser4a97d3
 
javaScriptCookies.pptx
javaScriptCookies.pptxjavaScriptCookies.pptx
javaScriptCookies.pptxMattMarino13
 
HTML5 Local Storage
HTML5 Local StorageHTML5 Local Storage
HTML5 Local StorageLior Zamir
 
Ch4(saving state with cookies and query strings)
Ch4(saving state with cookies and query strings)Ch4(saving state with cookies and query strings)
Ch4(saving state with cookies and query strings)Chhom Karath
 
Caching your rails application
Caching your rails applicationCaching your rails application
Caching your rails applicationArrrrCamp
 
Accelerating Rails with edge caching
Accelerating Rails with edge cachingAccelerating Rails with edge caching
Accelerating Rails with edge cachingMichael May
 
Tuning Your SharePoint Environment
Tuning Your SharePoint EnvironmentTuning Your SharePoint Environment
Tuning Your SharePoint Environmentvmaximiuk
 
PHP-Cookies-Sessions.pdf
PHP-Cookies-Sessions.pdfPHP-Cookies-Sessions.pdf
PHP-Cookies-Sessions.pdfHumphreyOwuor1
 

Similar a Lt local storage (20)

Maximize your Cache for No Cash
Maximize your Cache for No CashMaximize your Cache for No Cash
Maximize your Cache for No Cash
 
PHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONSPHP COOKIES AND SESSIONS
PHP COOKIES AND SESSIONS
 
Module-5_WTA_Managing State & jQuery
Module-5_WTA_Managing State & jQueryModule-5_WTA_Managing State & jQuery
Module-5_WTA_Managing State & jQuery
 
19_JavaScript - Storage_Cookies_students.pptx
19_JavaScript - Storage_Cookies_students.pptx19_JavaScript - Storage_Cookies_students.pptx
19_JavaScript - Storage_Cookies_students.pptx
 
19_JavaScript - Storage_Cookies-tutorial .pptx
19_JavaScript - Storage_Cookies-tutorial .pptx19_JavaScript - Storage_Cookies-tutorial .pptx
19_JavaScript - Storage_Cookies-tutorial .pptx
 
javaScriptCookies.pptx
javaScriptCookies.pptxjavaScriptCookies.pptx
javaScriptCookies.pptx
 
APEX & Cookie Monster
APEX & Cookie MonsterAPEX & Cookie Monster
APEX & Cookie Monster
 
HTML5 Local Storage
HTML5 Local StorageHTML5 Local Storage
HTML5 Local Storage
 
Cookies & Session
Cookies & SessionCookies & Session
Cookies & Session
 
Ch4(saving state with cookies and query strings)
Ch4(saving state with cookies and query strings)Ch4(saving state with cookies and query strings)
Ch4(saving state with cookies and query strings)
 
Caching your rails application
Caching your rails applicationCaching your rails application
Caching your rails application
 
Php cookies
Php cookiesPhp cookies
Php cookies
 
Sessions and cookies
Sessions and cookiesSessions and cookies
Sessions and cookies
 
Accelerating Rails with edge caching
Accelerating Rails with edge cachingAccelerating Rails with edge caching
Accelerating Rails with edge caching
 
Tuning Your SharePoint Environment
Tuning Your SharePoint EnvironmentTuning Your SharePoint Environment
Tuning Your SharePoint Environment
 
Session and Cookies
Session and CookiesSession and Cookies
Session and Cookies
 
Chapter 8 part1
Chapter 8   part1Chapter 8   part1
Chapter 8 part1
 
Session and cookies,get and post
Session and cookies,get and postSession and cookies,get and post
Session and cookies,get and post
 
State Management.pptx
State Management.pptxState Management.pptx
State Management.pptx
 
PHP-Cookies-Sessions.pdf
PHP-Cookies-Sessions.pdfPHP-Cookies-Sessions.pdf
PHP-Cookies-Sessions.pdf
 

Último

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 

Último (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 

Lt local storage

  • 3. What is local storage? • data stored in your local computer
 => faster loading :) • data persists even after you navigate away from the web site, close your browser tab, exit your browser, • Cookies and cache are also local storage
  • 4. review: cache and cookies • Cache: a temporary storage of web page resources stored on client’s machine
 for quicker loading of the web pages! • Cookies: a very small piece of information that is stored on the client’s machine by the web site and is sent back to the server each time a page is requested to store information 
 for tracking different characteristics related to user
  • 5. HTML5 Local Storage it’s a way for web pages to store named key/value pairs
 locally, within the client web browser
  • 6. Is it different from Cache or Cookies? • Cache: speed up loading the page (video, audio, text messages) • Cookies: store info about the user ! • localStorage: store info about the user to use on the server side to use on the client side
  • 7. Is it different from Cache or Cookies? • Cookie: user info to be used on the server side • localStorage: user info to be used on the client side function() { ! var name= document.getElementById('name').value; ! ! localStorage.setItem('name', name);! }); get ‘/’ do ! @user = User.find(session[:id]) erb: index end
  • 8. Is it different from Cache or Cookies? • Cookie: limited to 4 KB of data • localStorage: 5MG of data
  • 9. Is it different from Cache or Cookies? • Cookie: sent in every HTTP request • localStorage: not sent in request
  • 10. How to use localStorage • Set the key & value pair! • Retrieve the data! • Remove the data!
  • 11. function() { ! var name= document.getElementById('name').value; ! ! localStorage.setItem('name', name);! }); <input type="name" name="name" id=“name"> Set the key & value pair! localStorage[“name”] = name
  • 12. window.onload = function() { var name = localStorage.getItem('name'); ! if (name != "undefined" || name != "null") { document.getElementById('welcomeMessage').innerHTML = "Hello " + name + "!"; } else document.getElementById('welcomeMessage').innerHTML = "Hello!"; } } Retrieve the data! localStorage[“name”]
  • 14. Summary • wanna get a lot of user information and use it on the client side ?
 => use localStorage! • set, retrieve, remove the data!
 
 localStorage.setItem(“key”,”value”)
 localStorage[“key”]