Commit 46488729 by Arjun Jhukal

updated the cookie for th age

parent f8b6e951
......@@ -3,15 +3,32 @@ import { useAppSelector } from "@/hooks/hook";
import { Box, Button, Dialog, DialogContent, Typography } from "@mui/material";
import { useEffect, useState } from "react";
const AGE_COOKIE_KEY = "age_verified";
const ONE_DAY = 24 * 60 * 60;
export default function AgeVerificationModal() {
const user = useAppSelector((state) => state.auth.user);
const [open, setOpen] = useState(false);
const setAgeCookie = () => {
document.cookie = `${AGE_COOKIE_KEY}=true; max-age=${ONE_DAY}; path=/; SameSite=Lax`;
};
const getAgeCookie = () => {
return document.cookie
.split("; ")
.find((row) => row.startsWith(`${AGE_COOKIE_KEY}=`));
};
useEffect(() => {
setOpen(!user);
const ageVerified = getAgeCookie();
setOpen(!user && !ageVerified);
}, [user]);
const handleConfirmAge = () => {
setAgeCookie();
setOpen(false);
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment