Welcome to Discuss Everything Forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.


 

Reply to Thread

Post a reply to the thread: PHP Sessions Easy Question?

Your Message

Click here to log in

In what corner do we have Search box?

 
 

You may choose an icon for your message from this list

Additional Options

  • Will turn www.example.com into [URL]http://www.example.com[/URL].

Rate Thread

You may rate this thread from 1-star (Terrible) to 5-stars (Excellent) if you wish to do so.

Topic Review (Newest First)

  • 12-03-2012, 02:45 PM
    Cool Inferno

    PHP Sessions Easy Question?

    I'm feeling that I'm just having a brain fart right now, but this is driving me nuts! I'm simply trying to access a session variable from one page to the next. To test this out, I've made pages, test1.php and test2.php. The code for each is short and simple:

    test1:

    <?php
    session_start();
    $_SESSION['name'] = "default";
    echo "<html><body>Name = " . $_SESSION['name'] . "<br /><a href = 'test2.php'>Next</a></body></html>";
    ?>

    test2:

    <?php
    session_start();
    echo "<html><body>Name = " . $_SESSION['name'] . "</body></html>";
    ?>

    Now, test1 should by default display "Name = default" It does. On page 2, I'm looking for the same, but I'm getting "Name = "

    I was hoping someone would be able to see what easy mistake I've made that I'm just not catching right now. Thanks for your help!

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •