๋กœ์ผ“๐Ÿพ
article thumbnail

 

 

์ฟ ํ‚ค(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๋ฅผ ๋ˆŒ๋Ÿฌ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

profile on loading

Loading...