Link to home
Start Free TrialLog in
Avatar of aayushpuri
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
Avatar of rjdown
rjdown
Flag of United Kingdom of Great Britain and Northern Ireland image

Use the super global variable $_SESSION["message"] instead
Avatar of aolXFT
aolXFT



$message =& $_SESSION['message'];
$message = $_SESSION['message'];
ASKER CERTIFIED SOLUTION
Avatar of aolXFT
aolXFT

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial