Im very new to sessions. this is what im tryin gto do to help me understand how this works.

I have 3 files
-net.php
-flow.php
-show.php

How do I have a global variable on all three of these pages. What do I put on each page for this to work?

thanks!

    that didnt work ...someone help me out

      If that didn't work, then Sessions are not working on your web host and you won't be able to do sessions variables.

        no i mean that i dont understand what the hell to put on each file....how do u carry the sessions

        the first file where i have the variable that i want to set globally is this

        <?
        session_start();
        $_SESSION['showit'] = $_POST['name'];
        
        
        ?><form name="form1" method="post" action="test3.php">
          <input name="name" type="text" id="name" value="jeff">
          <input type="submit" name="Submit" value="Submit">
        </form>
        
        

        the second file to show that variable what do i put???

          please help im so frustrated!

            You almost got it. You just need to register each session var like this:

            session_start();
            session_register('showit');
            
            $_SESSION['showit'] = $_POST['name'];

            You only need to register each session variable once. Usually when you first use it. Then you can access it on any page like this:

            $_SESSION['showit']

            As long as you include session_start() at the top of each page you need it in.

            Hope that helps

              From the PHP User Manual:
              [color=FF0000]Caution: If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register()![/color]

                Instead of supplying an 'Oh yeah, look here I know more than you' response why don't you supply a link to why not to use session_register.

                  I will let the PHP user manual speak for itself.

                  session_register and $_SESSION together don't work reliably. There are countless threads on this forum of people who have gone through this.

                  The entire procedure for setting up a session is:

                  <?php
                  session_start();
                  $_SESSION['var1'] = 'my data';
                  ?>

                  The entire procedure for carrying that data to another page is:

                  <?php
                  echo "<A href=\"index2.php?".SID."\">Click here to go to Page 2.</a>";
                  ?>

                    I'm not asking anyone to justify the PHP users manual. I'm trying to find out why using session_register with $_SESSION is unreliable. What causes the unreliability?

                      I have tried your guys' ways and its still not working

                      okay

                      page1

                      <? 
                      session_start();
                      session_register('current_zone'); 
                      $_SESSION['current_zone'] = $_POST['current_zone'];
                      
                      ?>

                      page 2

                      <? session_start(); 
                      $_SESSION['current_zone'];
                      ?>
                      
                      
                      

                      correct?!??! whats wrong with this?

                        Get rid of session_register('current_zone');
                        Make sure $POST['current_zone'] has a value. Test it by doing

                        echo $_POST['current_zone'];

                        When you go to page 2, are you carrying a session ID?

                        In other words, you have to have page 1 link to page 2 or call page 2 while passing a session ID.

                        On page 1, you could have

                        <A href=\"page2.php?".SID."\">Go to page 2</a>

                        On page 2, you aren't doing anything with that $SESSION variable. Try

                        echo $_SESSION['current_zone'];

                          Originally posted by pahikua
                          I'm not asking anyone to justify the PHP users manual. I'm trying to find out why using session_register with $_SESSION is unreliable. What causes the unreliability?

                          And you've already seen the link. Follow it and read the bloody thing.

                            Write a Reply...