Calling session_start from a function

From: Date: Sun, 23 Jul 2000 04:48:15 +0000
Subject: Calling session_start from a function
Groups: php.general 
Request: Send a blank email to php-general+get-7753@lists.php.net to get a copy of this message
I have foo.php with: <?php include ("decode_session.h"); get_session_vars ("logged_in"); ?> and decode_session.h is: function get_session_vars () { foreach (array_values (func_get_args ()) as $arg) { global $$arg; } // start a previously-connected session session_start (); if (isset ($logged_in)) { echo "foo"; } else { echo "bar"; } } I know the session information is being saved correctly (and the variable logged_in is in the session database). From foo.php, if I: <?php include ("decode_session.h"); session_start (); if (isset ($logged_in)) { echo "foo"; } else { echo "bar"; } ?> then the output will be "foo". What do I need to do to get session_start() working from a function so the caller sees the variables? -- albert chin (china@thewrittenword.com)

« previous php.general (#7753) next »