PHP - Sessions and CookiesWhy is it important to delete the session cookie when destroying a session in PHP?ABecause session_destroy() automatically deletes the cookieBTo prevent the browser from sending an old session ID to the serverCTo reset all session variables to default valuesDTo start a new session with the same IDCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand role of session cookieThe session cookie stores the session ID on the user's browser and is sent with each request.Step 2: Importance of deleting cookieIf the cookie is not deleted, the browser keeps sending the old session ID, which may allow session reuse.Final Answer:To prevent the browser from sending an old session ID to the server -> Option BQuick 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 automaticallyConfusing cookie deletion with variable resetBelieving new session uses same ID
Master "Sessions and Cookies" in PHP9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PHP Quizzes Array Functions - Array key and value extraction - Quiz 12easy Classes and Objects - Why OOP is needed in PHP - Quiz 8hard Error and Exception Handling - Set_error_handler function - Quiz 5medium Error and Exception Handling - Error vs Exception in PHP - Quiz 3easy Inheritance and Polymorphism - Parent keyword behavior - Quiz 2easy Inheritance and Polymorphism - Final classes and methods - Quiz 5medium Interfaces and Traits - Multiple interface implementation - Quiz 15hard String Functions - String search functions (strpos, strstr) - Quiz 9hard String Functions - Trim functions - Quiz 5medium String Functions - Trim functions - Quiz 9hard