What is the primary purpose of a cookie in web applications ?

2026

What is the primary purpose of a cookie in web applications ?

  1. A.

    Store large amounts of data

  2. B.

    Execute server-side scripts

  3. C.

    Store small amounts of data on client side

  4. D.

    Encrypt data transmission

Attempted by 64 students.

Show answer & explanation

Correct answer: C

Cookies are small text files created by a web server and stored on the user's device (client side) via their web browser. Their primary purpose is to maintain stateful information between HTTP requests, which are inherently stateless. This allows websites to remember user preferences, login sessions, and shopping cart contents. Option C is correct because cookies are specifically designed to store small amounts of data, typically limited to 4KB per cookie. Option A is incorrect because cookies cannot store large amounts of data; databases or server-side storage are used for that. Option B is wrong because cookies contain static text data and cannot execute scripts; JavaScript handles client-side execution. Option D is incorrect because encryption of data transmission is handled by protocols like HTTPS (SSL/TLS), not cookies. Therefore, the main function of a cookie is to store small data fragments on the client side to enhance user experience and session management.

Explore the full course: Tpsc Assistant Technical Officer