简体   繁体   English

跨平台客户端存储的最佳方式?

[英]Best way for cross platform client storage?

I need a cross platform way to store data on the client without using cookies, because a token is being saved clientside which should not be sent to the server on each request. 我需要一种跨平台的方式来在不使用cookie的情况下在客户端上存储数据,因为令牌被保存在客户端,不应该在每个请求上发送到服务器。

Requirements 要求

  • old browser (IE6+) have to be supported 必须支持旧浏览器(IE6 +)
  • has to be working on mobile devices (in webviews) as well 必须在移动设备上工作(在网页浏览中)

You can't store data on the client without cookies. 没有cookie,您无法在客户端上存储数据。 You could pass the session ID in the URL. 您可以在URL中传递会话ID。 As an example with PHP: http://php.net/manual/en/session.idpassing.php but that's the best you can get. 以PHP为例: http//php.net/manual/en/session.idpassing.php,但这是你能得到的最好的。

I don't see a problem supporting IE6. 我没有看到支持IE6的问题。 Using 'progressive enhancement' you can provide a very basic site to older mobiles, IE6/7 and other crap. 使用“渐进增强”,您可以为旧手机,IE6 / 7和其他垃圾提供一个非常基本的网站。 Then, layer on the more advanced stuff to the devices that can handle it. 然后,将更高级的内容分层到可以处理它的设备上。 I don't test in IE6, but I'm 99% my sites work in it. 我不在IE6中测试,但我99%的网站都在使用它。

If you use JayData ItemStore API , there is a fallback mechanism while detecting the available local storage technologies. 如果您使用JayData ItemStore API ,则在检测可用的本地存储技术时会有回退机制。 The priority order is WebSQL, IndexedDB, HTML5 localStorage. 优先级顺序是WebSQL,IndexedDB,HTML5 localStorage。 The bad piece of news that you need a HTML5 browser. 你需要一个HTML5浏览器的坏消息。

Disclaimer: I'm member of the development team of the open-source JayData library 免责声明:我是开源JayData库开发团队的成员

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM