3

I have a index.php with a start_session(); at the top.

Then if you click on a menu item it calls a include(); page (lets say page B). There is no start_session(); at the top of that page because I thought because its included I can omit it.

in this page B there is a AJAX call to call a scripts page related to page B. On this page I would like to use a stored $_SESSION(); variable containing the username to do some things. I do start the page with...

if(session_id() == '') {
    session_start();
}

When I do a var_dump($GLOBALS); on this scripts page it contains

'_SESSION' => &
    array (size=2)
      'username' => string 'mo' (length=2)
      'administrator' => string '0' (length=1)

My question is, What is the ampersand & 's chars meaning in this case?

Can I use the $_SESSION(); variables as normal in this case?

morne
  • 4,035
  • 9
  • 50
  • 96

1 Answers1

3

It's a reference.
The ampersand (&) back references the array stored under the _SESSION key in the $GLOBALS array, when you try and access $_SESSION super global.

Zander Rootman
  • 2,178
  • 2
  • 17
  • 29