foreach ($_SESSION as $key => $val) {${$key} = $val;}
I don't understand the {${$hey}=$val;} especially.
Looks like it sets the value of a variable, whose name is the current value of $key, to the value in $val.
So if $key = "name", then it sets $name = $val.
Much easier to
extract ($_SESSION);
hth