Back to the 2023 paper

Module III: Basics of Web Programming

20232m

Differentiate cookies from session variables.

Worked SolutionAI Assisted
Basis Cookies Session variables
Storage location Client (browser) Server (only a session ID is kept on the client, usually in a cookie)
Security Less secure; user can view or modify them More secure; data stays on the server
Capacity About 4 KB per cookie Limited only by server memory or storage
Lifetime Persistent until the expiry date, or session-only Ends when the browser closes, on timeout, or on session_destroy()
Data types Strings only Any data type, including arrays and objects
Performance Sent with every request Uses server resources
PHP access setcookie(), COOKIE‘∣‘sessionstart()‘,‘_COOKIE` | `session_start()`, `_SESSION

Similar questions

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.