I was wondering wether it makes a difference in speed to save PHP SESSION Variables at the top of a script as Variables or just use the SESSION Variables through the entire script. e.g.
$_SESSION['bar'];
...
<p><?php echo $_SESSION['bar'] ?></p>
<p><?php echo $_SESSION['bar'][0] ?></p>
Or as explained above: Save the SESSION Variable first and then access that variable instead.
$bar = $_SESSION['bar'];
...
<p><?php echo $bar ?></p>
<p><?php echo $bar[0] ?></p>
Does it make any difference? Is PHP Requesting the SESSION Variables every single time from the server again?
Unless you do these session read/write operations millions of times (e.g. in a loop) you shouldn't be concerned with such micro optimizations. Even if you do them like that, I still think that PHP writes to session whenever that session is closed (not 100% sure about this last one).
Remember that premature optimization is the root of all evil. :)
On a more serious note: