Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
7
Help us understand the problem. What is going on with this article?
@flmil

sessionStorageを扱う

More than 1 year has passed since last update.

Sessionのテンプレート

//セッションへの格納
window.sessionStorage.setItem(['Key'],['Body']);

//セッションの個数の取得
window.sessionStorage.length

//セッションのBodyの取得
window.sessionStorage.getItem(['key']);

//指定したセッションの削除
window.sessionStorage.removeItem(['key']);

//全てのセッションの削除
window.sessionStorage.clear();

window.sessionStorage.setItem(['unique'],['UniqUniq']);
window.sessionStorage.setItem(['personality'],['PersPers']);

var test_size = window.sessionStorage.length
console.log(test_size); 
//結果 => 2

var test = window.sessionStorage.getItem(['unique']);
console.log(test);
//結果 => UniqUniq

window.sessionStorage.removeItem(['unique']);
var test = window.sessionStorage.getItem(['unique']);
console.log(test);
//結果 => nil

window.sessionStorage.clear();
var test1 = window.sessionStorage.getItem(['unique']);
var test2 = window.sessionStorage.getItem(['personality']);
console.log(test1);
console.log(test2);
//結果=> nil
//           nil
7
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
flmil
自分のためにと思って書いています。 もしよかったら参考にしてください。 全然知識ないので間違えを書くかもしれません。 その時はご指摘していただけると幸いです。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
7
Help us understand the problem. What is going on with this article?