You are designing a library to manage multiple user sessions in a web application. How can closures be efficiently used to manage individual session states securely?

  • Store session data in global variables
  • Use closures to encapsulate session data within functions
  • Use cookies to store session data
  • Use session variables provided by the web framework
Closures in JavaScript can be used to encapsulate session data within functions, providing a secure and isolated way to manage individual session states. Storing session data in global variables (option a) is not secure and can lead to data leakage. Using cookies (option c) is a separate technique for session management, and session variables provided by a web framework (option d) are framework-specific and may not utilize closures.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *