Check cookie for redirection

I am trying to redirect my user by checking a cookie using Cloudflare workers. The cookie name I m setting is login=true. So if the cookie exists user goes to app.xyz.com and if it doesn’t exist user goes to xyz.com. I have written a cookie setting function inside the login func. But safari won’t allow me to set the cookie for more than 7 days. How can I fix this problem?.