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

109
Views
How to clear the cookie when browsers tab is closed or entire browser is closed in React

I want to store the access tokens in cookies so that they are shareable across tabs, but my requirement is I want to clear the tokens when all the browser tabs are closed or the entire browser is closed. So I am really not sure what to provide in the expires column so that it can clear them on closing the browser tab.

I am not using localStorage because it is tough to clear tokens when the browser is closed, and the event listeners are not up to the mark.

And the same case for Session storage, it works like a charm, but it is hard to pass the token across tabs, and still using some workarounds, it is not up to the mark

So can anyone please help me on how to work on this requirement using cookies in react?

Thanks in advance!!!

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!