I meet the Cookies.expire doesn't work problem, cause by wrong way to set Cookies.default.
My stupid way is that, Cookies.default = { expires: 3600 }.
That stupid mistake will make the Cookies.default.path change to undefined, which will cause Cookies.set('key') set the cookie at current path.
Then when you use Cookies.expire('key') will not expire the Cookie key in the current path. You can still get the cookie by Cookie.get('key').
If someone meet the problem that Cookies.expire doesn't work as you wish. Maybe you set the Cookies.default with the stupid way , just like me
So, which way is the better way to set Cookies.default.
do the assign outside. Cookies.default = assign({}, Cookies.default, { expires: 3600 }).
do the assign inside cookie-js. Maybe will need a func setDefault, Cookies.setDefault({ expires: 3600 }).just like some other Project . eg: i18next, i18next.init({yourSetting}).
I meet the Cookies.expire doesn't work problem, cause by wrong way to set Cookies.default. My stupid way is that,
Cookies.default = { expires: 3600 }
. That stupid mistake will make the Cookies.default.path change toundefined
, which will causeCookies.set('key')
set the cookie atcurrent path
. Then when you useCookies.expire('key')
will not expire the Cookiekey
in thecurrent path
. You can still get the cookie byCookie.get('key')
.If someone meet the problem that Cookies.expire doesn't work as you wish. Maybe you set the Cookies.default with the stupid way , just like me
So, which way is the better way to set Cookies.default.
setDefault
, Cookies.setDefault({ expires: 3600 }).just like some other Project . eg: i18next, i18next.init({yourSetting}).