Bird
0
0

Why is it important to delete the session cookie when destroying a session in PHP?

hard📝 Conceptual Q10 of 15
PHP - Sessions and Cookies
Why is it important to delete the session cookie when destroying a session in PHP?
ABecause session_destroy() automatically deletes the cookie
BTo prevent the browser from sending an old session ID to the server
CTo reset all session variables to default values
DTo start a new session with the same ID
Step-by-Step Solution
Solution:
  1. Step 1: Understand role of session cookie

    The session cookie stores the session ID on the user's browser and is sent with each request.
  2. Step 2: Importance of deleting cookie

    If the cookie is not deleted, the browser keeps sending the old session ID, which may allow session reuse.
  3. Final Answer:

    To prevent the browser from sending an old session ID to the server -> Option B
  4. Quick Check:

    Delete cookie to stop old session ID reuse [OK]
Quick Trick: Delete session cookie to stop old ID reuse [OK]
Common Mistakes:
  • Thinking session_destroy() deletes cookie automatically
  • Confusing cookie deletion with variable reset
  • Believing new session uses same ID

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes