Hallo,
I'm writing some scripts at the moment, they all use one login system. Today I wanted to put some athentification code into a function, but the sessions do not work anymore although I'm using the $HTTP_SESSION_VARS array! Do you know a solution (I'm using Apache with Win2k)?
Alex
Thats becuz the $HTTP_SESSION_VARS wont be accessble inside a funtion or method. You will have to declare it as "global" like this:
function test() { global $HTTP_SESSION_VARS;
print_r($HTTP_SESSION_VARS); }
hope that helps.
cheers.
Thank you very much! I've always thought that the $HTTP_X_VARS arrays are glibal by default??
Well I've learned that they should always be on the global scope.
Read about other users having thoughts on the subject here:
http://www.php.net/manual/en/function.session-register.php
As far as I know, any variable used inside a PHP function (unlike C) is considered local. That's why you need to redeclare this as global.
if you are using PHP 4.10 ar higher you can use $_SESSION which does not need to be declared global.