How come PHP session cannot access anywhere? I mean if I want to display in a function, it will not display. But if click to go to next page, it will display. In a nutshell, as long as in a function, it will not display. How come?
Let me give a very simple exampple.
Page1.php
<?
$HTTP_SESSION_VARS["userid"]="Testing";
echo $HTTP_SESSION_VARS["userid"]; //Appear
f1();
function f1(){
echo $HTTP_SESSION_VARS["userid"]; //Did Not Appear
echo "No No"; //Appear
}
?>
Can someone explain why? Is it really neccessary to pass the session into the function before it can be used?
And I tried with:
session_start();
session register("userid");
Still doesn't work..
Why???