Session varibable problem, please help

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • effendi@epitome.com.sg

    Session varibable problem, please help

    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

    #2
    Re: Session varibable problem, please help

    do you have any code to demonstrate the problem?
    konstantin

    <effendi@epitom e.com.sg> wrote in message
    news:1102400930 .236618.236380@ f14g2000cwb.goo glegroups.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]


    Comment

    • effendi@epitome.com.sg

      #3
      Re: Session varibable problem, please help


      konsu wrote:[color=blue]
      > do you have any code to demonstrate the problem?
      > konstantin
      >
      > <effendi@epitom e.com.sg> wrote in message
      > news:1102400930 .236618.236380@ f14g2000cwb.goo glegroups.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_V ARS with PHP 4.0.6 or less
      if (!isset($_SESSI ON['IsAdminLoggedI n'])) {
      //(!isset($_SESSI ON['IsAdminLoggedI n']))
      header("Locatio n: index_login.php ?ALE=0");
      }
      ?>

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

      Comment

      • konsu

        #4
        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($_SESSI ON['IsAdminLoggedI n']))
        {
        echo('ok');
        }
        ?>

        must be a configuration problem on your server.


        Comment

        • Ken Robinson

          #5
          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']['IsAdminLoggedI n'] 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

          Comment

          • effendi@epitome.com.sg

            #6
            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($_SESSI ON['IsAdminLoggedI n']))
            > {
            > echo('ok');
            > }
            > ?>
            >
            > must be a configuration problem on your server.[/color]

            Comment

            • Pedro Graca

              #7
              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_p ath" 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!

              Comment

              • effendi@epitome.com.sg

                #8
                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_p ath" 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_pa th 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_globa ls" function is needed to be turned
                on on hte server as on mine it is set to off.

                Comment

                • Pedro Graca

                  #9
                  Re: Session varibable problem, please help

                  effendi@epitome .com.sg wrote:[color=blue]
                  >
                  > Pedro Graca wrote:[color=green]
                  >> I could bet that "session.save_p ath" is badly configured.[/color]
                  >
                  > I found that my session.save_pa th 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_pa th points to an *existing*
                  directory and then restart your web-server,
                  [color=blue]
                  > I was wondering if "register_globa ls" 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_global s 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!

                  Comment

                  • effendi@epitome.com.sg

                    #10
                    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($_SESSI ON['IsAdminLoggedI n']))
                    logically it should,. Shouldn't it?

                    Comment

                    • Steve

                      #11
                      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($_SESSI ON['IsAdminLoggedI n']))
                      > logically it should,. Shouldn't it?
                      >[/color]

                      No, bcause you set one variable, and test one with another name, perhaps?

                      Comment

                      • effendi@epitome.com.sg

                        #12
                        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($_SESSI ON['IsAdminLoggedI n']))
                        > > logically it should,. Shouldn't it?
                        > >[/color]
                        >
                        > No, bcause you set one variable, and test one with another name,[/color]
                        perhaps?

                        Comment

                        • effendi@epitome.com.sg

                          #13
                          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($_SESSI ON['IsAdminLoggedI n']))
                          > > > logically it should,. Shouldn't it?
                          > > >[/color]
                          > >
                          > > No, bcause you set one variable, and test one with another name,[/color]
                          > perhaps?[/color]

                          Comment

                          Working...