Re: Strange Session Problem
| From: | Shaun | Date: | Fri, 02 Jul 2004 12:19:59 +0000 |
| Subject: | Re: Strange Session Problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-189533@lists.php.net to get a copy of this message | ||
Ooops, sorry about the attempted fake URL!
"Shaun" <shaunthornburgh@hotmail.com> wrote in message
news:20040702120043.72328.qmail@pb1.pair.com...
> Hi,
>
> I have a config file which i include in every page:
>
> <snip>
> class object {};
>
> $CFG = new object;
>
> $CFG->dbhost = "localhost";
> $CFG->dbname = "x";
> $CFG->dbuser = "x";
> $CFG->dbpass = "x";
>
> $connection = mysql_connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass);
> @mysql_select_db($CFG->dbname) or die( "Unable to select database");
>
> $CFG->wwwroot = http://www.xxx.com;
> $CFG->dirroot = "/usr/home/xxx/public_html";
> $CFG->templatedir = "$CFG->dirroot/templates";
> $CFG->admindir = "$CFG->wwwroot/admin";
> $CFG->usersdir = "$CFG->wwwroot/users";
>
> session_start();
> </snip>
>
> On my login form I am attempting to initialise the seesion variables if
the
> login values are correct:
>
> <snip>
> include("application.php");
>
> $user = verify_login($_POST[username], $_POST[password]);
>
> if($user){
> // register user sessions
> $ses_user_id = $user["User_ID"];
> $ses_name = $user["User_Name"];
> $ses_user_type = $user["User_Type"];
>
> session_register("ses_user_id");
> session_register("ses_name");
> session_register("ses_user_type");
>
> include("$CFG->usersdir"); // ***This line causes session problems***
> exit;
> }
> </snip>
>
> The highlighted line is causing problems. If i leave it as it is the
> following page (users/index.php) will not display session variables
>
> <snip>
> echo '$ses_user_type = '.$ses_user_type.'<br>'.
> $ses_user_id = '.$ses_user_id.'<br>';
> </snip>
>
> displays:
>
> $ses_user_type =
> $ses_user_id =
>
> However, if I rewrite the offending line to:
>
> include("users/index.php");
>
> then it worke fine and displays the session variables correctly:
>
> $ses_user_type = Administrator
> $ses_user_id = 1
>
> I would be most grateful if someone could lend a hand here as this is as
far
> as I have been able to narrow down the problem to in the last 10 hours!!!