Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    session not passing from page to page

    ok so I have this code:
    Code:
    $reso = $_GET['r'];
    if ($reso == 2)
    	$_SESSION['reso'] = $reso;
    else if ($reso == 1)
    	$_SESSION['reso'] = $reso;
    this sets $_SESSION to whatever to $reso number is, if it is in the URL ie: mysite.com/index.php?r=1
    however if the page is just normal mysite.com/index.php
    The session is unset for some reason, and it is not passed onto the next page

    what is wrong with this?

  • #2
    New Coder
    Join Date
    Mar 2004
    Posts
    92
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by o0katz0o
    ok so I have this code:
    Code:
    $reso = $_GET['r'];
    if ($reso == 2)
    	$_SESSION['reso'] = $reso;
    else if ($reso == 1)
    	$_SESSION['reso'] = $reso;
    this sets $_SESSION to whatever to $reso number is, if it is in the URL ie: mysite.com/index.php?r=1
    however if the page is just normal mysite.com/index.php
    The session is unset for some reason, and it is not passed onto the next page

    what is wrong with this?
    You must have session_start(); as the very first line of coding on each page you want to use sessions on...

    -peace

  • #3
    New Coder
    Join Date
    Apr 2004
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i do have session_start() at the beginning of the line
    I have it retrieving from a db instead now, although i still don't understand WHY that code wasn't working, considering i have other SESSION variables right under that line that works perfectly.
    oh well, what a mystery


  •  

    Posting Permissions

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