How does Cookie set the expiration time to clear when the current page is closed?

  Cookie.set("token", res.data.data.token);

how do I set the expiration time for Cookie on this basis? Set to clear when the page is closed?

Jun.21,2021

then why do you use Cookie,? this case is more suitable for Session Storage.


in this case, you can use session directly or use session storage


to try this when there is only one page, which means clear the cookie
< body onbeforeunload= "document.cookie=''" >


before the page closes.

clear cookie before unloading the page

window.addEventListener('beforeunload', funciton (){
    Cookie.set('token', null);
}, false)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b376b3-2c074.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b376b3-2c074.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?