Last active
August 29, 2015 14:14
-
-
Save tyfkda/5e2b024bd98da3752f54 to your computer and use it in GitHub Desktop.
HTML5 storage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function() { | |
| // sessionStorage: Live until session end. | |
| // localStorage: Live forever. | |
| // Size limit: 5MB / domain. | |
| var storage = sessionStorage; // or localStorage; | |
| // Save: 値は文字列化される(toString())ので、数値などはいいが、オブジェクトはJSONなどでエンコードしておく必要がある | |
| storage.setItem('KEY', value); | |
| // Load. | |
| storage.getItem('KEY'); // ない場合にはnull | |
| }()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment