create your own Cookie
2022年5月1日小于 1 分钟
create your own Cookie
Question
We can get and set cookie by document.cookie
.
document.cookie = 'bfe=dev'
// "bfe=dev"
document.cookie = 'bfe1=dev1'
// "bfe1=dev1"
document.cookie
// "bfe=dev; bfe1=dev1"
Please create your own myCookie
.
- it should support get and set.
document.myCookie = 'bfe=dev'
// "bfe=dev"
document.myCookie = 'bfe1=dev1'
// "bfe1=dev1"
document.myCookie
// "bfe=dev; bfe1=dev1"
- there a few options to cookie, but in this problem, you only need to support
max-age
which means the cookie should be deleted after certain time(in seconds).
document.myCookie = 'bfe=dev; max-age=1'
// "bfe=dev; max-age=1"
document.myCookie
// "bfe=dev"
after 1 second
document.myCookie
// ""
- in your code, please enable
myCookie
ininstall()
and remove the logic inuninstall()
, these are used in judging.
Code
// enable myCookie
function install() {
// your code here
}
// disable myCookie
function uninstall() {
// your code here
}