์ฟ ํค(Cookie) ์ ์ฅํ๊ธฐ
var setCookie = function(name, value, exp) {
var date = new Date();
date.setTime(date.getTime() + exp*24*60*60*1000);
document.cookie = name + '=' + value + ';expires=' + date.toUTCString() + ';path=/';
};
// setCookie(๋ณ์์ด๋ฆ, ๋ณ์๊ฐ, ๊ธฐ๊ฐ);
setCookie("expend", "true", 1);
์ฟ ํค(Cookie) ๊ฐ์ ธ์ค๊ธฐ
var getCookie = function(name) {
var value = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
return value? value[2] : null;
};
// getCookie(๋ณ์์ด๋ฆ)
var is_expend = getCookie("expend");
console.log("์ฟ ํค is_expend๋ณ์์ ์ ์ฅ๋ ๊ฐ: "+is_expend);
์ฟ ํค(Cookie) ์ญ์ ํ๊ธฐ
var deleteCookie = function(name) {
document.cookie = name + '=; expires=Thu, 01 Jan 1999 00:00:10 GMT;';
}
// deleteCookie(๋ณ์์ด๋ฆ)
deleteCookie('name');
๊ฒฐ๊ณผํ์ธ
๊ฐ๋ฐ์ ๋๊ตฌ๋ฅผ ํต๋๋ค
Application์ ๋๋ฆ ๋๋ค.
์ผ์ชฝ Storage๋ฅผ ๋๋ฅด๊ณ Cookies๋ฅผ ๋๋ฌ ํ์ธํฉ๋๋ค.
'...' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Kubernetes] ์ค๋ธ์ ํธ(Object)๋? (0) | 2021.08.20 |
---|---|
[Kubernetes] ์ค๋ธ์ ํธ ์์ฑ์ run, create, apply ์ฐจ์ด (0) | 2021.08.20 |
[Elastic Search+Java] Java์์ Elastic Search ์์ํ๊ธฐ (0) | 2021.08.19 |
[Elastic Search+Java] ์ฌ์ฉ์ ์ธ์ฆ ๊ตฌํํ๊ธฐ Basic Authentication (0) | 2021.08.19 |
[ElasticSearch] ElasticSearch ์ธ๋ถ ์ ์ํ๊ธฐ (0) | 2021.08.18 |