Connecting Tech Pros Worldwide Help | Site Map

Session varibable problem, please help

effendi@epitome.com.sg
Guest
 
Posts: n/a
#1: Jul 17 '05
I have been having error messages relating to a session variable. I did
a print_r of the $session and I got the following results

Array ( [language] => english [languages_id] => 1 [selected_box] =>
configuration [IsAdminLoggedIn] => 1 )
Fatal error: Session variable IsAdminLoggedIn is not globally defined


As you could see in the print out, the variable IsAdminLogged in is set
and yet I get the error message, does anyone know what is going on?
Thanks

konsu
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Session varibable problem, please help


do you have any code to demonstrate the problem?
konstantin

<effendi@epitome.com.sg> wrote in message
news:1102400930.236618.236380@f14g2000cwb.googlegr oups.com...[color=blue]
>I have been having error messages relating to a session variable. I did
> a print_r of the $session and I got the following results
>
> Array ( [language] => english [languages_id] => 1 [selected_box] =>
> configuration [IsAdminLoggedIn] => 1 )
> Fatal error: Session variable IsAdminLoggedIn is not globally defined
>
>
> As you could see in the print out, the variable IsAdminLogged in is set
> and yet I get the error message, does anyone know what is going on?
> Thanks
>[/color]


effendi@epitome.com.sg
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Session varibable problem, please help



konsu wrote:[color=blue]
> do you have any code to demonstrate the problem?
> konstantin
>
> <effendi@epitome.com.sg> wrote in message
> news:1102400930.236618.236380@f14g2000cwb.googlegr oups.com...[color=green]
> >I have been having error messages relating to a session variable. I[/color][/color]
did[color=blue][color=green]
> > a print_r of the $session and I got the following results
> >
> > Array ( [language] => english [languages_id] => 1 [selected_box] =>
> > configuration [IsAdminLoggedIn] => 1 )
> > Fatal error: Session variable IsAdminLoggedIn is not globally[/color][/color]
defined[color=blue][color=green]
> >
> >
> > As you could see in the print out, the variable IsAdminLogged in is[/color][/color]
set[color=blue][color=green]
> > and yet I get the error message, does anyone know what is going on?
> > Thanks
> >[/color][/color]

Konstantin

This is the code I had in my pages

<?php
session_start ();

// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
if (!isset($_SESSION['IsAdminLoggedIn'])) {
//(!isset($_SESSION['IsAdminLoggedIn']))
header("Location: index_login.php?ALE=0");
}
?>

I hope this shed some light on how I used the session variable.
Regards

konsu
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Session varibable problem, please help


i placed this code in to a separate php file and it displayed 'ok':

<?php
session_start ();
if (!isset($_SESSION['IsAdminLoggedIn']))
{
echo('ok');
}
?>

must be a configuration problem on your server.


Ken Robinson
Guest
 
Posts: n/a
#5: Jul 17 '05

re: Session varibable problem, please help



effendi@epitome.com.sg wrote:[color=blue]
> I have been having error messages relating to a session variable. I[/color]
did[color=blue]
> a print_r of the $session and I got the following results
>
> Array ( [language] => english [languages_id] => 1 [selected_box] =>
> configuration [IsAdminLoggedIn] => 1 )
> Fatal error: Session variable IsAdminLoggedIn is not globally defined
>
>
> As you could see in the print out, the variable IsAdminLogged in is[/color]
set[color=blue]
> and yet I get the error message, does anyone know what is going on?
> Thanks[/color]

No, the variable $_SESSION['configuration']['IsAdminLoggedIn'] is set.
That is different.

Change your code to reflect this.

Also, when using print_r on arrays, use:

echo '<pre>';print_r ($array);echo '</pre>';
This will format the dump much prettier on the screen.

Ken

effendi@epitome.com.sg
Guest
 
Posts: n/a
#6: Jul 17 '05

re: Session varibable problem, please help


Konsu

Thanks for trying that out, do you know what settings on the server
could affect the session variable?



konsu wrote:[color=blue]
> i placed this code in to a separate php file and it displayed 'ok':
>
> <?php
> session_start ();
> if (!isset($_SESSION['IsAdminLoggedIn']))
> {
> echo('ok');
> }
> ?>
>
> must be a configuration problem on your server.[/color]

Pedro Graca
Guest
 
Posts: n/a
#7: Jul 17 '05

re: Session varibable problem, please help


effendi@epitome.com.sg top-posted:[color=blue]
> ... do you know what settings on the server
> could affect the session variable?[/color]

I could bet that "session.save_path" is badly configured.

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
effendi@epitome.com.sg
Guest
 
Posts: n/a
#8: Jul 17 '05

re: Session varibable problem, please help



Pedro Graca wrote:[color=blue]
> effendi@epitome.com.sg top-posted:[color=green]
> > ... do you know what settings on the server
> > could affect the session variable?[/color]
>
> I could bet that "session.save_path" is badly configured.
>
> --
> Mail to my "From:" address is readable by all at[/color]
http://www.dodgeit.com/[color=blue]
> == ** ## !! ------------------------------------------------ !! ## **[/color]
==[color=blue]
> TEXT-ONLY mail to the whole "Reply-To:" address ("My Name"[/color]
<my@address>)[color=blue]
> may bypass my spam filter. If it does, I may reply from another[/color]
address!


Hi

I found that my session.save_path was set to a folder called /tmp
which didn't exist. I created the folder in the directory but
unfortunately no effect.

I was wondering if "register_globals" function is needed to be turned
on on hte server as on mine it is set to off.

Pedro Graca
Guest
 
Posts: n/a
#9: Jul 17 '05

re: Session varibable problem, please help


effendi@epitome.com.sg wrote:[color=blue]
>
> Pedro Graca wrote:[color=green]
>> I could bet that "session.save_path" is badly configured.[/color]
>
> I found that my session.save_path was set to a folder called /tmp
> which didn't exist. I created the folder in the directory but
> unfortunately no effect.[/color]

If you don't want to change php.ini, create the "tmp" directory under
the root directory ("C:\tmp")

Or change php.ini so that session.save_path points to an *existing*
directory and then restart your web-server,
[color=blue]
> I was wondering if "register_globals" function is needed to be turned
> on on hte server as on mine it is set to off.[/color]

No, no need to turn register_globals on.
--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
effendi@epitome.com.sg
Guest
 
Posts: n/a
#10: Jul 17 '05

re: Session varibable problem, please help


My hosting provider has C:\tmp created and re-started the server, Still
no luck.

Sorry if this is a stupid question.

Since the variable [IsAdminLogged] exists when I printed $_session, why
does it not picked up for line

if (!isset($_SESSION['IsAdminLoggedIn']))
logically it should,. Shouldn't it?

Steve
Guest
 
Posts: n/a
#11: Jul 17 '05

re: Session varibable problem, please help


effendi@epitome.com.sg wrote:[color=blue]
> My hosting provider has C:\tmp created and re-started the server, Still
> no luck.
>
> Sorry if this is a stupid question.
>
> Since the variable [IsAdminLogged] exists when I printed $_session, why
> does it not picked up for line
>
> if (!isset($_SESSION['IsAdminLoggedIn']))
> logically it should,. Shouldn't it?
>[/color]

No, bcause you set one variable, and test one with another name, perhaps?
effendi@epitome.com.sg
Guest
 
Posts: n/a
#12: Jul 17 '05

re: Session varibable problem, please help


I'll try that. Thanks for your suggestion. Will update everyone on the
outcome.

Steve wrote:[color=blue]
> effendi@epitome.com.sg wrote:[color=green]
> > My hosting provider has C:\tmp created and re-started the server,[/color][/color]
Still[color=blue][color=green]
> > no luck.
> >
> > Sorry if this is a stupid question.
> >
> > Since the variable [IsAdminLogged] exists when I printed $_session,[/color][/color]
why[color=blue][color=green]
> > does it not picked up for line
> >
> > if (!isset($_SESSION['IsAdminLoggedIn']))
> > logically it should,. Shouldn't it?
> >[/color]
>
> No, bcause you set one variable, and test one with another name,[/color]
perhaps?

effendi@epitome.com.sg
Guest
 
Posts: n/a
#13: Jul 17 '05

re: Session varibable problem, please help


I tried what Steve suggested and replaced IsAdminLogged with Language
and I didn't get any error. What does this suggest? Does it mean the
variable IsAdminLogged wasn't set correctly?

Regards

effendi@epitome.com.sg wrote:[color=blue]
> I'll try that. Thanks for your suggestion. Will update everyone on[/color]
the[color=blue]
> outcome.
>
> Steve wrote:[color=green]
> > effendi@epitome.com.sg wrote:[color=darkred]
> > > My hosting provider has C:\tmp created and re-started the server,[/color][/color]
> Still[color=green][color=darkred]
> > > no luck.
> > >
> > > Sorry if this is a stupid question.
> > >
> > > Since the variable [IsAdminLogged] exists when I printed[/color][/color][/color]
$_session,[color=blue]
> why[color=green][color=darkred]
> > > does it not picked up for line
> > >
> > > if (!isset($_SESSION['IsAdminLoggedIn']))
> > > logically it should,. Shouldn't it?
> > >[/color]
> >
> > No, bcause you set one variable, and test one with another name,[/color]
> perhaps?[/color]

Closed Thread