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

82
Views
losing js-cookies after closing browser in react

im using context api to manage language in react app ... and for saving language to client browser i decided to use js-cookie but i lose the cookie as soon as i close the browser , how can i prevent this behaviour?

import Cookies from "js-cookie";
import React ,{useState} from "react";

const Language = React.createContext({
    language:"",
    activeLanguageFnOr:(data) =>{}
});

export const LanguageProvider = (props) =>{
    const [activeLanguage , setActiveLanguage] = useState(Cookies.get('currentLang'));
    if(Cookies.get('currentLang') === undefined){
        Cookies.set("currentLang" , 'arabic' ,{sameSite: 'strict', secure: true , expires:3});
        setActiveLanguage('arabic')   
     }
    const  activeLang =  (data) =>{
        setActiveLanguage(data);
    }
    return <Language.Provider value={{language:activeLanguage , activeLangFn:activeLang}}>{props.children}</Language.Provider>
}
export default Language;
about 4 years ago · Juan Pablo Isaza
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!