Checking Session Vars in Functions

From: Date: Fri, 09 Aug 2002 08:13:24 +0000
Subject: Checking Session Vars in Functions
Groups: php.general 
Request: Send a blank email to php-general+get-111781@lists.php.net to get a copy of this message
I have PHP 4.2.2 with register_globals=off. It seems like session vars stored in $_SESSION[] aren't visible to functions. For example, this won't work for me: $status = user_access(); function user_access() { if ( isset($_SESSION['user']) ) { return 1; } else { return 0; } } Result is that $status = 0 even though I know those session vars are set. if ( isset($_SESSION['user']) ) { echo "Logged In"; } else { echo "Not Logged In"; } Result for the above is "Logged In" even though I'm checking the same session var. My script does include session_start(); as well. So, is there a way I access session vars stores in $_SESSION[] from a custom function? Thanks! Monty

« previous php.general (#111781) next »