session variable is available and set but value is hidden
Posted: Wed Jul 03, 2002 8:55 pm
Hi I have a strange problem that has recurred in different code yet I cannot find out where my code is buggy. Anyone have any ideas?
Basically....... my PHP scripts makes use of functions which are contained in other included/required php files.
In authenticating a user at login my login script uses some functions from a function library (included in the login script). A successful login entails one of those functions setting some session variables.
As the user logs in successfully in the login script I immediately include() next_page.php.
This next_page.php starts with include(functions_library2.php) which contains the declaration for the function myFunc() which it (next_page.php that is) promptly calls.
Now ... myFunc needs to access one of those session variable which was set at login.
I have verified that the session variables are visible to a printSessVars.php script I quickly coded for debugging purposes. Also next_page.php CAN DIRECTLY access the session variables created at login and echo their values......... so no worries my session is fine and working.
My problem ..... and I cannot work out why this is happening ...... is that the the session variable's value is not visible from WITHIN myFunc() as it should be, having been session_registered etc etc ....... I am having to resort to passing it as an argument to myFunc().......
Now, I thought that session variables (being to all intents and purposes 'global') would be accessible inside these library functions, surely they are available anywhere in current scope so long as session_start() has been called in the current scope/script etc etc
So I can echo the value of the session variable directly inside the included next_page.php but if it I try to echo its value from within myFunc() inside next_page.php ALTHOUGH myFunc() returns boolean true on checking whether session_is_registered('mysessionvariable') .... all the same it outputs no value .."_" .. nothing. This is mysterious because just before the function call, in next_page, I can access and echo the session var.
Does anyone have any idea what on earth is going on here?
thanks in advance
Qizmo
Basically....... my PHP scripts makes use of functions which are contained in other included/required php files.
In authenticating a user at login my login script uses some functions from a function library (included in the login script). A successful login entails one of those functions setting some session variables.
As the user logs in successfully in the login script I immediately include() next_page.php.
This next_page.php starts with include(functions_library2.php) which contains the declaration for the function myFunc() which it (next_page.php that is) promptly calls.
Now ... myFunc needs to access one of those session variable which was set at login.
I have verified that the session variables are visible to a printSessVars.php script I quickly coded for debugging purposes. Also next_page.php CAN DIRECTLY access the session variables created at login and echo their values......... so no worries my session is fine and working.
My problem ..... and I cannot work out why this is happening ...... is that the the session variable's value is not visible from WITHIN myFunc() as it should be, having been session_registered etc etc ....... I am having to resort to passing it as an argument to myFunc().......
Now, I thought that session variables (being to all intents and purposes 'global') would be accessible inside these library functions, surely they are available anywhere in current scope so long as session_start() has been called in the current scope/script etc etc
So I can echo the value of the session variable directly inside the included next_page.php but if it I try to echo its value from within myFunc() inside next_page.php ALTHOUGH myFunc() returns boolean true on checking whether session_is_registered('mysessionvariable') .... all the same it outputs no value .."_" .. nothing. This is mysterious because just before the function call, in next_page, I can access and echo the session var.
Does anyone have any idea what on earth is going on here?
thanks in advance
Qizmo