zoukankan      html  css  js  c++  java
  • sessionStorage 和 localStorage 、cookie

    sessionStorage 和 localStorage
    html5中web storage包括两种储存方式:sessionStorage 和 localStorage
    sessionStorage用于本地存储一个会话(session)中的数据,这些数据只有在同一个会话

    中的页面才能访问并且当会话结束后数据也随之销毁。因此sessionStorage不是一种持久

    化的本地存储,仅仅是会话级别的存储。

    localStorage用于持久化的本地存储,除非主动删除数据,否则数据是永远不会过期的
    web storage和cookie的区别:
    Web Storage的概念和cookie相似;
    区别:
    Web Storage它是为了更大容量存储设计,Cookie的大小受到限制,并且每次请求一个新页

    面时,cookie都会被发送过去,无形之间浪费了资源。
    web storage 提供了一系列的方法,steItem、getItem、removeItem、clear等方法;
    cookie需要开发者自己封装方法,如基于JQuery 的封装的js。 jquery.cookie.js,
    $.cookie(str)从cookie中取参数 $.cookie(str,str1) 往cookie中设置参数。
    cookie的作用是与服务器交互,作为http规范的一部份而存在,而web storage 仅仅是本

    地存储数据而存在。
    sessionStorage 和 localStorage都具有相同的操作方法,例如setItem、getItem和

    removeItem、clear等
    get和set两个大家一看都知道就不说了:
    sessionStorage.removeItem(key,value) 指定一个要删除对象的key
    sessionStorage.clear()删除sessionStorage中的所有信息。

  • 相关阅读:
    POJ 1401 Factorial
    POJ 2407 Relatives(欧拉函数)
    POJ 1730 Perfect Pth Powers(唯一分解定理)
    POJ 2262 Goldbach's Conjecture(Eratosthenes筛法)
    POJ 2551 Ones
    POJ 1163 The Triangle
    POJ 3356 AGTC
    POJ 2192 Zipper
    POJ 1080 Human Gene Functions
    POJ 1159 Palindrome(最长公共子序列)
  • 原文地址:https://www.cnblogs.com/gjmfg/p/6225053.html
Copyright © 2011-2022 走看看