Node.js API Masterclass with Express and MongoDB - Sending JWT in a Cookie

Node.js API Masterclass with Express and MongoDB - Sending JWT in a Cookie

Assessment

Interactive Video

Information Technology (IT), Architecture

University

Hard

Created by

Quizizz Content

FREE Resource

The video tutorial explains how to manage token storage using cookies and local storage, emphasizing security considerations. It introduces the Cookie Parser package for handling cookies in Node.js applications. The tutorial covers creating a function to send token responses, setting cookie expiration to match JWT expiration, and sending cookies and JSON data in responses. Testing the implementation with Postman is demonstrated, and setting the secure flag for cookies in production environments is discussed.

Read more

7 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is one reason for using cookies to store tokens instead of local storage?

Cookies are easier to access.

Cookies can be more secure.

Cookies are faster to read.

Cookies have unlimited storage.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the primary purpose of the Cookie Parser package?

To encrypt cookies.

To parse cookie headers and populate request cookies.

To delete cookies from the server.

To increase cookie storage capacity.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method is used to integrate the Cookie Parser middleware into the application?

app.insert()

app.include()

app.use()

app.add()

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the custom function created in the third section?

To delete cookies from the client.

To handle token generation, cookie creation, and response sending.

To encrypt the token before sending.

To log user activities.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How is the expiration of the cookie set in the custom function?

By calculating 30 days from the current date.

By using a random number generator.

By using the default browser settings.

By setting a fixed date.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What tool is used to test the implementation of token and cookie handling?

Docker

GitHub

Postman

Visual Studio Code

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When should the secure flag be set to true for cookies?

Never, as it is not necessary.

Always, regardless of the environment.

Only in development environments.

Only in production environments.