You have a PHP script and you need to store information about a user session. How would you do this using a superglobal?

  • Use the $_SESSION superglobal.
  • Use the $_COOKIE superglobal.
  • Use the $_SERVER superglobal.
  • Use the $_GLOBALS superglobal.
The correct option is 1. To store information about a user session in PHP, you would use the $_SESSION superglobal. The $_SESSION superglobal is an associative array that allows you to store and access session variables. It is used to maintain session data across multiple page requests for a specific user. By storing data in $_SESSION, you can preserve user-specific information throughout their interaction with your web application. The session data is stored on the server and can be accessed across different pages or scripts as long as the session is active. Learn more: https://www.php.net/manual/en/reserved.variables.session.php
Add your answer
Loading...

Leave a comment

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