Orginally, I use the following ajax to set cookie.
function setCookieAjax(){
$.ajax({
url: `${Web_Servlet}/setCookie`,
contentType: \'application/
You can use default javascript cookies set method. this working perfect.
createCookieInHour: (cookieName, cookieValue, hourToExpire) => {
let date = new Date();
date.setTime(date.getTime()+(hourToExpire*60*60*1000));
document.cookie = cookieName + " = " + cookieValue + "; expires = " +date.toGMTString();
},
call java scripts funtion in react method as below,
createCookieInHour('cookieName', 'cookieValue', 5);
and you can use below way to view cookies.
let cookie = document.cookie.split(';');
console.log('cookie : ', cookie);
please refer below document for more information - URL