From b2beaa7c2b793c132d633e8648dfa192c8403efb Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Wed, 5 Jul 2023 15:40:05 +0100 Subject: [PATCH] changed how the value of login type is read from the cookie --- src/components/AuthPages/Login/index.jsx | 39 ++++++++++++++++-------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/components/AuthPages/Login/index.jsx b/src/components/AuthPages/Login/index.jsx index aca1aee..8c7619f 100644 --- a/src/components/AuthPages/Login/index.jsx +++ b/src/components/AuthPages/Login/index.jsx @@ -139,24 +139,37 @@ export default function Login() { // In order to update the selected login type whenever the component renders // useEffect(() => { - // document.cookie.includes("loginType=family") ? "loginfamily" : "loginfull" - - // Set the loginType cookie to remember the user's selection - // document.cookie = "loginType=family; expires=Session; path=/;"; - - // Clear the loginType cookie if the user switches to loginfull + // Clear the loginType cookie if the user switches to loginfull // document.cookie ="loginType=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; // }, []); useLayoutEffect(()=>{ // checks the cookie in order to set the login type before components mounts - if(document.cookie.includes("loginType=family")){ - setLoginType('family') - }else if(document.cookie.includes("loginType=full")){ - setLoginType('full') - }else{ - setLoginType('full') + // if(document.cookie.includes("loginType=family")){ + // setLoginType('family') + // }else if(document.cookie.includes("loginType=full")){ + // setLoginType('full') + // }else{ + // setLoginType('full') + // } + function readCookie(cname) { // checks the cookie in order to set the login type before components mounts + let name = cname + "="; + let decoded_cookie = decodeURIComponent(document.cookie); + let carr = decoded_cookie.split(';'); + for(let i=0; i { setMail("");