Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
using cookie for multiple devices in nextjs

I'm using nextjs and I want to use the cookie to share some data on multiple devices. when I set data in cookies on current devices, and check on another device, I see that data doesn't exist.

in _app.js

import { CookiesProvider } from "react-cookie"

<CookiesProvider>
          <UserProvider>
            <CartProvider>
              <Layout
              >
                <Component {...pageProps} />
              </Layout>
            </CartProvider>
          </UserProvider>
        </CookiesProvider>

in cartProvider

import { useCookies } from "react-cookie";


export default function CartProvider({ children }: Props) {
  const [cookies, setCookie, removeCookie] = useCookies([
    "cart_token",
    "token",
  ]);
  useEffect(()=>{
  API.get(`cart/show/${temp_token ? temp_token : ""}`)
              .then((res) => {
                setCookie("cart_token", res.data.data.cart_token, {
                  path: "/",
                  maxAge: 3600 * 24 * 360,
                  sameSite: true,
                });
                })
  },[])
  }
  

But when I check cookie on another device, I cant see cart_token in the cookie

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To add to @juliomalves comment, in your case, you would need to store the cart items in your backend and then in a new device, fetch it back when the same user logs in

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!