Hello,
I was wondering if there is a way to have the splash widget cookie expire after a certain period of time? This way, after the period is over, the user would be presented with the splash screen and have to agree to the terms again.
I found the following code in the widget.js file of the splash widget.
onOkClick: function() {
var isFirstKey = this._getCookieKey();
if (this._requireConfirm) {
if (this.confirmCheck.getValue()) {
if (TokenUtils.isInConfigOrPreviewWindow() || this._confirmEverytime) {
cookie(isFirstKey, null, {expires: -1});
} else {
cookie(isFirstKey, false, {
expires: 1000,
path: '/'
});
}
this.close();
}
} else {
if (this._showOption) {
if (!TokenUtils.isInConfigOrPreviewWindow() && this.confirmCheck.getValue()) {
cookie(isFirstKey, false, {
expires: 1000,
path: '/'
});
}
} else {
cookie(isFirstKey, null, {expires: -1});
}
this.close();
}
},
Does the expires: 1000 represent one thousand days?
Any input is appreciated. Thank you.
William
William,
I am not sure how they are using expires but if you look at the dojo/cookie doc it points to the MDN help for cookies
Document.cookie - Web APIs | MDN
and if you want to make the cookie expire after a certain time then you should use max-age.
//86400 = 1 day
cookie(isFirstKey, false, {
max-age: 86400,
path: '/'
});
Hi Robert,
Thank you for the links and script. I had looked at the API Documentation - The Dojo Toolkit Version 1.10 for cookie, and the first example used {expires: 5} for an expiration 5 days from now. I thought maybe it was being used that way in WAB. I'll try your code and see what happens tomorrow afternoon.
Thanks.
William