Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

Which storage mechanism is safest for an authentication token?

  1. A localStorage
  2. B sessionStorage
  3. C An httpOnly cookie
  4. D A global JavaScript variable
Answer

An httpOnly cookie

An httpOnly cookie cannot be read by JavaScript, so a single XSS flaw does not expose the session. Adding secure and sameSite strengthens it further.

All Javascript MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as