Session Will not stay active?

Discussion in 'PHP' started by mokimofiki, Aug 21, 2008.

  1. #1
    I will start a session and it works for that first page it goes to and then when I go to the next page in the same domain the variables are no longer there? Any ideas on how to make these variables stay stored during the current session to be called at a later time as long as my site isn't left?

    <?php 
    session_start(); 
     
    
    //store session data
    $_session['sppkgtotal'] = $_POST["sppkgtotal"];
    $_session['chasstotal'] = $_POST["chasstotal"];
    $_session['plumbtotal'] = $_POST["plumbtotal"];
    $_session['heattotal'] = $_POST["heattotal"];
    $_session['floortotal'] = $_POST["floortotal"];
    $_session['flcovtotal'] = $_POST["flcovtotal"];
    $_session['wallstotal'] = $_POST["wallstotal"];
    $_session['cabinetstotal'] = $_POST["cabinetstotal"];
    $_session['electtotal'] = $_POST["electtotal"];
    $_session['fireptotal'] = $_POST["fireptotal"];
    $_session['rooftotal'] = $_POST["rooftotal"];
    $_session['extertotal'] = $_POST["extertotal"];
    $_session['drwintotal'] = $_POST["drwintotal"];
    $_session['trimtotal'] = $_POST["trimtotal"];
    $_session['appltotal'] = $_POST["appltotal"];
    $_session['misctotal'] = $_POST["misctotal"];
    
    ?>
    Code (markup):

     
    mokimofiki, Aug 21, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    Lol broodmolen, that's kinda lot to read :D
     
    EricBruggema, Aug 21, 2008 IP
  3. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #3
    And you're sure that you have session_start(); in the top of the other page?

    on the page where you define the sessions, have you tried to write print_r($_SESSION) in the bottom of the file to check if they're really defined?
     
    elias_sorensen, Aug 22, 2008 IP
  4. Ilyes

    Ilyes Banned

    Messages:
    129
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    make sur that session_start is the first thing in all your page, don't write any script before session_start :)
     
    Ilyes, Aug 22, 2008 IP
  5. nice.wallpapers

    nice.wallpapers Active Member

    Messages:
    142
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Hi ,


    There is lot of difference between $_SESSION and $_session , please try with cap on.

    Thanks,
     
    nice.wallpapers, Aug 22, 2008 IP
  6. nice.wallpapers

    nice.wallpapers Active Member

    Messages:
    142
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #6
    Hi,

    This is the right way
    <?php 
    session_start(); 
     
    
    //store session data
    $_SESSION['sppkgtotal'] = $_POST["sppkgtotal"];
    $_SESSION['chasstotal'] = $_POST["chasstotal"];
    $_SESSION['plumbtotal'] = $_POST["plumbtotal"];
    $_SESSION['heattotal'] = $_POST["heattotal"];
    $_SESSION['floortotal'] = $_POST["floortotal"];
    $_SESSION['flcovtotal'] = $_POST["flcovtotal"];
    $_SESSION['wallstotal'] = $_POST["wallstotal"];
    $_SESSION['cabinetstotal'] = $_POST["cabinetstotal"];
    $_SESSION['electtotal'] = $_POST["electtotal"];
    $_SESSION['fireptotal'] = $_POST["fireptotal"];
    $_SESSION['rooftotal'] = $_POST["rooftotal"];
    $_SESSION['extertotal'] = $_POST["extertotal"];
    $_SESSION['drwintotal'] = $_POST["drwintotal"];
    $_SESSION['trimtotal'] = $_POST["trimtotal"];
    $_SESSION['appltotal'] = $_POST["appltotal"];
    $_SESSION['misctotal'] = $_POST["misctotal"];
    
    ?>
    PHP:
    Thanks,
     
    nice.wallpapers, Aug 22, 2008 IP
  7. *LESTAT*

    *LESTAT* Peon

    Messages:
    97
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    awesome, glad to see your all fixed up now. hope the site is workin well now
     
    *LESTAT*, Aug 22, 2008 IP
  8. mokimofiki

    mokimofiki Well-Known Member

    Messages:
    444
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #8
    I believe that with all the information above I should be in great shape. I can't test it till I get back to work in the morning although i'm satisfied that it should be fine at that point.

    Thank you all for your responses this is a very helpfull forum :)
     
    mokimofiki, Aug 24, 2008 IP