Unit 6: Cookies and Sessions, users and authentication - Subjective Questions

INT253 — Web Development In Python Using Django • Practice Questions with Detailed Answers

20 questions

1

Explain the concept of cookies in Django. Describe how cookies are created, accessed, modified, and deleted in a Django application.

2

Describe Django sessions and explain how session data is stored and retrieved in views.

3

Compare cookies and sessions in Django with respect to storage, security, capacity, lifetime, and typical uses.

4

Explain how to configure sessions in a Django project and mention the important settings and middleware involved.

5

Write and explain a Django view that uses a session to implement a simple shopping cart.

6

Explain the Django User model and describe how a new user can be created programmatically.

7

Describe the process of managing users in Django, including updating, deactivating, deleting, and checking user account properties.

8

Explain the difference between authentication and authorization in Django.

9

Explain the purpose and usage of Django's authenticate() function.

10

Describe how the Django login() and logout() functions work and explain their effect on the session.

11

Explain how to configure login and logout URLs in Django using built-in authentication views.

12

Write a custom Django login view using authenticate() and login(), and explain each step.

13

Explain how the @login_required decorator is used to protect Django views.

14

Describe how to use request.user in Django views and explain the difference between an anonymous user and an authenticated user.

15

Explain how to restrict a Django view using a user's permissions or group membership.

16

Describe the complete request flow when an unauthenticated user accesses a protected Django view.

17

Explain how cookies and sessions should be secured in a Django application.

18

Distinguish between session-based login and storing login information manually in a cookie.

19

Explain the role of CSRF protection in Django login and logout forms.

20

Describe the purpose of LoginView and LogoutView and compare them with custom authentication views.