0

I have a site that changes whenever a new location is changed. The location choices is by using a drop down. And on change calls this function:

    function PROD_CHANGE_LOC() {
      location_change = document.getElementById("PROD_SEL_LOC").value;
      varURL = "http://" + varServerAddr +
        "/hourly_ft_wip/production_line/prod_line_loc.php?location_change=" +
        location_change, LOAD(varURL, "LOCATION");

      setTimeout(function() {
        location.reload();
      }, 100);
    }

prod_line_loc.php just contains:

session_start();
$_SESSION['HOURLY_FT_WIP']['PROD_LOC'] = $_REQUEST['location_change'];
$_SESSION['HOURLY_FT_WIP']['PROD_TESTER'] = 'ALL';

And it returns to my main page that sets location by using this:

if(!isset($_SESSION['HOURLY_FT_WIP']['PROD_LOC'])){
    $_SESSION['HOURLY_FT_WIP']['PROD_LOC'] = 'EOLPHL';
}
else{
    $_SESSION['HOURLY_FT_WIP']['PROD_LOC'] = $_SESSION['HOURLY_FT_WIP']['PROD_LOC'];
}

This is working in our server, but we had to transfer to a new server and sometimes the session is changed. But sometimes it doesn't. Are there any settings to look that might affect this?

The only difference I see in them is in our old server it is located in var/www/folder but in our new server it is located in var/www/html/folder

Also the reason I have a sleep function it doesn't work in Firefox without that.

aozora
  • 423
  • 3
  • 13

2 Answers2

0

As stated:

session_start();

needs to be on every php page; in cases where you are embedding ajax calls it also needs to be on the ajax/php pages.

You can use:

session_name();

if you want to make sure your using the same session

you can also use database storage for your sessions which may fit more within your means.

As an edit:

    if(!isset($_SESSION)) {
   session_start();
 }

This is what should be on every page. If the session has been started it wont come back with an error if not it will start. This way you wont lose the session between pages.

0

I found the solution. I don't understand why or how it happened. But the solution is instead of:

$_SESSION['HOURLY_FT_WIP']['PROD_LOC'] = $_REQUEST['location_change'];

it should be:

$_SESSION['HOURLY_FT_WIP']['PROD_LOC'] = $_GET['location_change'];

This magically solved my problem. Anyway thank you for all those who answered and comment.

aozora
  • 423
  • 3
  • 13
  • Off topic advice, be sure not to use $_REQUEST, instead use specific like your answer $_GET['VARIABLE']; For more information... http://stackoverflow.com/questions/1924939/request-vs-get-and-post – Wesley Brian Lachenal Aug 25 '15 at 02:59