registering session variables doesn't work in functions

From: Date: Sun, 24 Dec 2000 02:26:26 +0000
Subject: registering session variables doesn't work in functions
Groups: php.general 
Request: Send a blank email to php-general+get-31727@lists.php.net to get a copy of this message
Hi all, Don't know if anyone has seen this yet, but if you know the answer to why this is happening and if it can be fixed, I'd really appreciate the help :( I am starting to use sessions. At this stage I am only using them in cookies. This is because I haven't worked out how to use URL's for the session id at all. In my login.php, I check a users login. If the username and password match the entry in the database, I want to start a session. I then call a function in a library of functions that I am using here... So the code looks as follows : require("../include/Authfunctions.inc.php"); session_start(); if (!$user_auth || $user_auth == "") { check_user_auth($HTTP_SERVER_VARS,$HTTP_POST_VARS); } If I try and do the session_register("variable_name") in the check_user_auth function, then the sess_blah file in /tmp contains the names of all the variables that I am trying to register but no values. If however, I do the following : require("../include/Authfunctions.inc.php"); session_start(); if (!$user_auth || $user_auth == "") { $user_details = check_user_auth($HTTP_SERVER_VARS,$HTTP_POST_VARS); $user_level = $user_details["user_level"]; $user_first_name = $user_details["user_first_name"]; $user_last_name = $user_details["user_last_name"]; $user_email_address = $user_details["user_email_address"]; $user_name = $user_details["user_name"]; $user_auth = $user_details["user_auth"]; session_register("user_name"); session_register("user_level"); session_register("user_first_name"); session_register("user_last_name"); session_register("user_email_address"); session_register("user_auth"); session_register("acl_level"); } everything works fine. The session is setup properly and I simply have to do a session_start() at the top of every page where I want to have access to the session variables. My main question is why doesn't registering session variables in functions work, but it does work fine if I return the values to the calling functions and register them there? -- A Complete Luser <acompleteluser@penguinpowered.org.uk>

« previous php.general (#31727) next »