aayushpuri
asked on
Session variables problem in functions
I am having problems with initializing session variables inside functions
While writing PHP scripts I need to set some session variables inside some functions
Example:
function some_function()
{
...........
session_register("message" );
$message="You are NOT authorized to view this page";
........
}
The same code for setting session variables in working fine when I use in the main part of the PHP i.e. not inside any function.
Can anyone figure out my mistake in setting session variables??
Suggestions and solutions are welcome
-Aayush
While writing PHP scripts I need to set some session variables inside some functions
Example:
function some_function()
{
...........
session_register("message"
$message="You are NOT authorized to view this page";
........
}
The same code for setting session variables in working fine when I use in the main part of the PHP i.e. not inside any function.
Can anyone figure out my mistake in setting session variables??
Suggestions and solutions are welcome
-Aayush
Use the super global variable $_SESSION["message"] instead
$message =& $_SESSION['message'];
$message = $_SESSION['message'];
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.