frankcollins3 / Next-Water-App

Happy, Healthy Water Cycling App that tracks user/human fluid intake.
https://next-water-app.vercel.app
1 stars 0 forks source link

client cookie setting 🚫chrome-tools-> app -> cookies [10:42pm] #62

Closed frankcollins3 closed 11 months ago

frankcollins3 commented 11 months ago

attempting to do: set cookies for user when they log in. serverside. Just found out about Doing the same in clientside

error: res is not defined in setCookie() function which is a serverside execution.

proposed approach: 0: this is already an attempt to use client setting of cookie to accomplish same end goal but without having res object available document.cookie = token=${loggedInUser.token}; httpOnly; max-age=${7 * 24 * 60 * 60}; path=/;;

frankcollins3 commented 11 months ago

πŸ‘ export const JWTsecretKeyMaker = () => { return crypto.randomBytes(64).toString('hex') } const token = jwt.sign({ id: user.id }, SECRET_KEY); πŸ‘ // no http only key. acknowledging potential security implications and this being a regular next app giving it a pass document.cookie = token=${loggedInUser.token}; max-age=${7 * 24 * 60 * 60}; path=/;; πŸš”πŸš«πŸš”πŸš«πŸš”πŸš«πŸš”πŸš«πŸš”πŸš«πŸš”πŸš«πŸš”πŸš«πŸš”πŸš«πŸš”πŸš«πŸš”πŸš«πŸš”πŸš«πŸš”πŸš«πŸš”πŸš«πŸš”πŸš«πŸš”πŸš«πŸš”πŸš«

frankcollins3 commented 11 months ago

πŸ‘ Screen Shot 2023-07-17 at 10 54 15 PM