I used this to set a cookie in my react application. It expires with hte session though. How can I store this cookie so it lasts beyond the session so it remains if the browser is closed and reopened?
export default function App() {
const [classnameTr,setClassname] = useState<string>("checkbox-row1");
const [classnameLabel, setClassnameLabel] = useState<string>("my-label-black");
const cookies = new Cookies();
function setCookie() {
cookies.set('certDiscCookie', 'certDiscCookieSet', { path: '/' });
console.log("Cookies: " + cookies.get('certDiscCookie'));
}
function getCookie() {
if (cookies.get('certDiscCookie') === "certDiscCookieSet") {
setColor();
}
}
return (
<div className="App">
<header className="App-header">
<div className="checkbox-div">
<table className="checkbox-table">
<tbody>
<td className="tr2-td2"><button className="certDiscButtonSet" onClick={() => setCookie()}>Set Cookie</button></td>
<td className="tr3-td3"><button className="certDiscButtonGet" onClick={() => getCookie()}>Get Cookie</button></td>
</tr>
</tbody>
</table>
</div>
</header>
</div>
);
}