From the course: Node.js: Security

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Use cookie attributes

Use cookie attributes

From the course: Node.js: Security

Start my 1-month free trial

Use cookie attributes

- [Instructor] Cookie attributes determine the proper use of cookie sessions. With these types of attributes you have better control over how your cookie sessions are used and where. Let's explore a few attributes that can be set in cookies and then introduce what packages can be used to set them in your application. When you create a cookie, you have a few options or attributes you can add. For example, you can set secure. This is an attribute that will only send a cookie if the request is over HTTPS. You can also set HttpOnly, which means you can prevent the cookie from being accessed by JavaScript. You can also define the cookie's scope by defining which domain can access it and even be more specific with the actual path to access it. If you'd like to set a persistent cookie, you can also set the expire date with the expiry attribute. So now let's explore a few packages you can use to set your cookies. The first one is the base cookies package that comes with JavaScript. So you can…

Contents