You have to understand the difference between server-side and client-side languages. PHP is server-side and therefore your browser will never know anything that happens in the PHP code, as long as it is not returned to the client (the browser in this case).
You can change your code (on the server!) to echo out data that you want to see in your browser, like so:
echo $_SESSION["foo"];
echo $bar;
This will send the value of the respective variable to the client. Apart from that (or other methods of sending data to the output, like using e.g. var_dump()
), you can not see the values in your browser!
Now for your first question about the session there is a bit of a speciality: While you can not directly "see" the session in the browser, in the default configuration of PHP you will get sent a session cookie that is named PHPSESSID
to your client. You can infer from that, that a session was indeed started by looking it up in the response headers.