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

278
Views
How to use httpOnly on the client side when using jwt for authentication?

I understand how to set the cookie to be httpOnly on the server side when using express and jwt.

res.cookie("jwt", accessToken, { secure: true, httpOnly: true })

However how can we leverage the httpOnly on the client side to make the authentication process secure and prevent the cookie from being hijacked? Can you explain with an example please?

I am also trying to understand the difference between accessing a cookie when httpOnly is false and another cookie when httpOnly is true. I understand the latter will return empty string but where do we use it on the client side when using jwt for authentication. Should we just send an ajax call and not to bother about anything else?

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

0

You should not store JWT tokens directly in the cookie, as anyone looking at the cookies in the browser can steal the cookie. The cookie should be encrypted using strong encryption if you want to store it in the cookie.

HttpOnly will block JavaScript from accessing the cookie and it is best practice to always set in all important cookies. Also you should add the secure attribute to all cookies. Also do consider setting the SameSite attribute to make it even more secure.

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!