#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    [SOLVED] I am failing at sessions please help.


    Hi,

    I want to pass along some data from one page to the next, without the user seeing it(so without GET).

    I decided to use sessions for it, if there is a better solution I'd be glad to hear about it.
    The problem is that the data I add to the session on the first page, is not available on the second.

    Here is a minimal working example:
    page1.php:
    PHP Code:
    <?php
    session_start
    ();  
    $_SESSION['test'] = "data";
    ?>
    <html><body><a href="page2.php">next</a></body></html>
    page2.php:
    PHP Code:
    <html><body><?php echo $_SESSION['test']; ?></body></html>
    Probably I am understanding the whole sessions thing all wrong.
    So, what do I do wrong and/or how should I do it otherwise?

    Thanks in advance!
    Last edited by Oebele; December 4th, 2012 at 01:57 PM. Reason: Problem solved
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,340
    Rep Power
    594
    It looks to me like you are missing a 'session_start' on page2.php.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0
    That indeed fixed it. I did not read that in any of the tutorials I read...

    Must be the quickest solved problem on a forum I ever encountered, thanks!

IMN logo majestic logo threadwatch logo seochat tools logo