老熟女激烈的高潮_日韩一级黄色录像_亚洲1区2区3区视频_精品少妇一区二区三区在线播放_国产欧美日产久久_午夜福利精品导航凹凸

重慶分公司,新征程啟航

為企業提供網站建設、域名注冊、服務器等服務

Web數據存儲中如何淺析Cookie、UserData、SessionStorage、WebSqlDatabase

這篇文章將為大家詳細講解有關Web數據存儲中如何淺析Cookie、UserData、SessionStorage、WebSqlDatabase ,文章內容質量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。

創新互聯-專業網站定制、快速模板網站建設、高性價比方正網站開發、企業建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式方正網站制作公司更省心,省錢,快速模板網站建設找我們,業務覆蓋方正地區。費用合理售后完善,十多年實體公司更值得信賴。

Cookie

它是標準的客戶端瀏覽器狀態保存方式,可能在瀏覽器誕生不久就有Cookie了,為什么需要Cookie 這個東東?由于HTTP協議沒有狀態,所以需要一個標志/存儲來記錄客戶瀏覽器當前的狀態,保證客戶瀏覽器和服務器通訊時可以知道客戶瀏覽器當前的狀態。Cookie就是記錄這個狀態的容器,Cookie在每次請求的時候都被帶回到服務器,從而保證了Server可以知道瀏覽器當前的狀態,由于Cookie會被帶回到Server,所以Cookie的內容不能存太多,最多不能超過4K,4K 限制的介紹 http://ec.europa.eu/ipg/standards/cookies/index_en.htm
其中一段內容為:

A browser is only required to store up to 300 cookies overall and maintain only the last 20 from each domain. The maximum size of a cookie is 4K of disk space.

但是在一些場景下可能需要存儲超過4K或者更多的數據,但是這些數據不用在每次請求的時候被帶回到服務器,只要能在客戶的瀏覽器上保存住,并且可以方便的被Javascript讀寫就可以了,這種需求尤為在中大型RIA的應用場景下更加的迫切,部分數據放在客戶瀏覽器,節約帶寬,提高瀏覽速度。HTML5標準已經替我們想到了滿足這種需求的方案:sessionStorage , webSqlDatabase, 微軟的IE 有 userData 方案。


userData
微軟對USERDATA的介紹: http://msdn2.microsoft.com/en-us/library/ms531424(VS.85).aspx
其中一段內容為:

Security Alert:For security reasons, a UserData store is available only in the same directory and with the same protocol used to persist the store.
Security Alert:Using this behavior incorrectly can compromise the security of your application. Data in a UserData store is not encrypted and therefore not secure. Any application that has access to the drive where UserData is saved has access to the data. Therefore, it is recommended that you not persist sensitive data like credit card numbers. For more information, see Security Considerations: DHTML and Default Behaviors.
……
The userData behavior persists data across sessions, using one UserData store for each object. The UserData store is persisted in the cache using the save and load methods. Once the UserData store has been saved, it can be reloaded even if Microsoft Internet Explorer has been closed and reopened.
Setting the userData behavior class on the html, head, title, or style object causes an error when the save or load method is called.

userData可以在同目錄同協議下相互訪問,長期存儲在客戶機器上。最大存儲空間也增大了很多。userData需要綁定到一個Dom元素上使用。在userData的method中有removeAttribute方法。經過測試代碼發現removeAttribute方法好像不是很管用,需要使用像cookie過期的方式,才可以徹底的刪除一個userData Attribute。
在 http://www.itwen.com/04web/11skill/skill20060918/60588.html 中介紹說userData存儲在X:\Documents and Settings\當前用戶\UserData\ 目錄下。具體細節MS在userData說明文檔中沒有具體說明。


sessionStorage
HTML5 標準對 sessionStorage的介紹: http://www.whatwg.org/specs/web-apps/current-work/
其中對 sessionStorage 的介紹:

This specification introduces two related mechanisms, similar to HTTP session cookies [RFC2965], for storing structured data on the client side.
The first is designed for scenarios where the user is carrying out a single transaction, but could be carrying out multiple transactions in different windows at the same time.
Cookies dont really handle this case well. For example, a user could be buying plane tickets in two different windows, using the same site. If the site used cookies to keep track of which ticket the user was buying, then as the user clicked from page to page in both windows, the ticket currently being purchased would "leak" from one window to the other, potentially causing the user to buy two tickets for the same flight without really noticing.
To address this, this specification introduces the sessionStorage DOM attribute. Sites can add data to the session storage, and it will be accessible to any page from that origin opened in that window.

Html5 sessionStorage Demo: http://html5demos.com/storage
下面是根據 http://www.blogjava.net/emu/archive/2006/10/04/73385.html 中提到的IE FF 兼容userData的測試代碼:

代碼如下:


function isIE() {
return !!document.all;
}
function initUserData() {
if (isIE()) document.documentElement.addBehavior("#default#userdata");
}
function saveUserData(key, value) {
var ex;
if (isIE()) {
//IE
with (document.documentElement) try {
load(key);
setAttribute("value", value);
save(key);
return getAttribute("value");
} catch (ex) {
alert(ex.message)
}
} else if (window.sessionStorage) {
//FF 2.0+
try {
sessionStorage.setItem(key, value)
} catch (ex) {
alert(ex);
}
} else {
alert("Error occured in user data saving. your browser do not support user data.");
}
}
function loadUserData(key) {
var ex;
if (isIE()) {
//IE
with (document.documentElement) try {
load(key);
return getAttribute("value");
} catch (ex) {
alert(ex.message); return null;
}
} else if (window.sessionStorage) {
//FF 2.0+
try {
return sessionStorage.getItem(key)
} catch (ex) {
alert(ex)
}
} else {
alert("Error occured in user data loading. your browser do not support user data.")
}
}
function deleteUserData(key) {
var ex;
if (isIE()) {
//IE
with (document.documentElement) try {
load(key);
expires = new Date(315532799000).toUTCString();
save(key);
}
catch (ex) {
alert(ex.message);
}
} else if (window.sessionStorage) {
//FF 2.0+
try {
sessionStorage.removeItem(key)
} catch (ex) {
alert(ex)
}
} else {
alert("Error occured in user data deleting. your browser do not support user data.")
}
}


userData和sessionStorage共同的特點就是:這兩個對象都可以存儲比cookie大的多的多內容。并且不會隨每次請求帶回到服務器端。但是根據Html5標準和測試發現userData和sessionStorage有很多地方是不同的。

下面是一個測試頁面:
Web數據存儲中如何淺析Cookie、UserData、SessionStorage、WebSqlDatabase 

其中的 SetInsurance link 會操作javascript 在IE下用userData寫數據, 在FF下用sessionStore寫數據。在IE下的情況是:關閉IE或者重啟機器寫入的值都不會丟失。在FF下的情況很有意思:在本頁面寫入的值在本頁面可以訪問,在由本頁面所打開的其它頁面可以訪問。但是就算本頁面開著,在導航欄里輸入地址,打開本頁面,存入的值就不能訪問了。在本頁面存入的值,在它的父頁面(打開這個頁面的頁面)是訪問不到的。又看了看Html5標準。sessionStorage 的全名是:Client-side session and persistent storage of name/value pairs 意思估計是存儲在Client的內容是有session 會話的,存儲的值由session會話所維系,一旦session會話中斷或者丟失,存入的值也就隨之消失了。所以當頁面沒有session(父頁面,由地址欄打開的頁面),是取不到值的。當FF關閉或者重啟機器必然也就取不到值了。


webSqlDatabase
webSqlDatabase在HTML5 標準中是非常Cool的一個東東, 用Javascript寫SQL查詢,數據庫就在瀏覽器里,這在以前幾乎不敢想象。不過今天Safari, Chrome, Opera 都已經支持了,兩個webSqlDatabase 的 Demo 頁面: http://html5demos.com/database http://html5demos.com/database-rollback
W3C 對WEBSQLDATABASE 的介紹頁面: http://dev.w3.org/html5/webdatabase/
WiKi上一個簡明的說明: http://en.wikipedia.org/wiki/Web_SQL_Database

From W3C: "...an API for storing data in databases that can be queried using a variant of SQL"
Web SQL Database is supported by Google Chrome[1], Opera and Safari but will not be implemented by Mozilla(Firefox)[2] who instead propone Indexed Database API access.

不知道 HTML 5 的 SQLDB 會被瀏覽器支持的怎么樣, 不過sessionStorage看上去已經可以基本滿足需求了。

關于Web數據存儲中如何淺析Cookie、UserData、SessionStorage、WebSqlDatabase 就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。


網站名稱:Web數據存儲中如何淺析Cookie、UserData、SessionStorage、WebSqlDatabase
本文來源:http://www.xueling.net.cn/article/pesgho.html

其他資訊

在線咨詢
服務熱線
服務熱線:028-86922220
TOP
主站蜘蛛池模板: 国产精品嫩草33av在线 | 国产免费丝袜调教视频爱 | 亚洲一级在线看 | 国产一在线精品一区在线观看 | 美日韩在线观看 | 久亚州在线播放 | 污黄啪啪网18以下勿进 | 亚洲国产成人无码AV在线播放 | 国产乱妇乱子在线播放视频 | 特黄特色大片免费播放器图片 | 黄色福利网站在线观看 | 成人天堂视频在线观看 | 国产熟睡乱子伦视频 | 91久久精品国产91久久性色也 | 午夜国产亚洲欧美 | 国产一区三区三区 | 一级一片免费看 | 国产又粗又大又硬点视频 | 青草99 | 欧美日韩国产综合在线 | 国产成人一区二区啪在线观看 | 成人三区四区 | 四虎网站最新地址 | 精品久久一区 | 成午夜精品一区二区三区 | 国产亚洲精品一区在线播放 | 亚洲精品无码久久久久久久久久久久久 | 欧美性猛交╳xx╳动态图 | 日本中文字幕一区 | 最近免费中文字幕中文高清 | 日韩欧美精品一区二区三区 | 国产精品亚洲成在人线 | 一区二区在线免费观看视频 | 亚洲富人天堂视频 | 成年人网站在线 | 黄色片大全在线观看 | 日韩一级片 | 啊啊av| 国产精品久久一区 | 日韩亚洲精品国产第二页 | 少妇被粗大的猛烈进出96影院 |