The old out of the box version of webchat used to remember a user across sessions when accessed through the same browser. I assume this was through the use of cookies? The new version ("gemini") does not do this. Every time I close the browser window and open again from the same browser, a new ID is sent, thus I no longer have access to saved userState information. To reclaim formatting, I switched over to botframework-webchat via directline and have the same issue. There is an explicit input for userID, and I have no idea how to make this consistent for a particular user.
I am not a web developer and have no need at this time to make this a robust implementation. I simply want to make this work the same way the former out of the box webchat worked. Can anyone shed some light on how that previous version worked, and/or how I can make the directline version have the same functionality?
Edit: Based on Steven's comment to the answer below, I tried to implement get/set cookies, but it is not working. Below is the code I tried. I can see through console that I am getting in to the if statement and userID is being generated, but it's not getting saved (I don't see it in Application>Storage>Cookies so it's not just the get not working). Please advise!
function setCookie(name,value,days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
document.cookie = name+'=; Max-Age=-99999999;';
}
if (!getCookie('userID')) {
console.log('in if');
var userID = Date.now() + '_' + Math.random().toString().substr(2, 9);
console.log(userID);
setCookie('userID',userID,999);
}
console.log('out of if');