JavaScript · Middle · Question 41 of 75

Why is a cookie with the HttpOnly flag safer than a regular one?

Explanation

HttpOnly blocks access via document.cookie. Session cookies also get Secure (HTTPS only) and SameSite (CSRF protection). That's why session tokens are safer in such cookies than in localStorage.

Further reading

Problem with a question

JavaScript · Middle · question 41

Test yourself

Take the JavaScript · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz