From the course: Node.js: Security

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Use cookie attributes

Use cookie attributes - Node.js Tutorial

From the course: Node.js: Security

Use cookie attributes

- [Instructor] Cookie attributes determine the proper use of cookie sessions and provide better control over how and where they are used. For example, the secure attribute ensures that a cookie is only sent over HTTPS, safeguarding its transmission. The HTTPOnly attribute prevents the cookie from being accessed by JavaScript, offering protection against cross site scripting attacks, and so on so forth. The SameSite attribute restricts cookies from being sent with cross site requests, offering options such as restrict to block all cross origin requests, lags for limited cross origin navigation, and non-fulfill cross site functionality, which requires the secure attribute. Additionally, the domain and path attributes allow you to define the scope of a cookie, specifying which domains and paths can access it. Persistent cookies can be managed by setting an expiration date with the expires attribute or a lifespan using max-age. These attributes provide developers with precise control over…

Contents