PHP session variable works on local machine, but not server?
Posted: Fri Jun 05, 2009 1:53 pm
I'm experiencing a strange unexplainable issue using PHP sessions if anyone has the time please help me identify the problem.
I have a form tool where users can select various SELECT fields to create a custom RF cable assembly. Each time a user selects a SELECT field value, the value is stored in a SESSION variable via the GET method. Here is one of my SELECT fields.
Here is where I catch the value of GET and store in a SESSION
ON my localhost testing server, this was working great! When I set the value of the other SELECT fields, the SESSION variables remained constant. The problem i noticed when I uploaded my script to the live server. For some reason the $_SESSION['cable'] variable would be erased when I set another SELECT field. I haven't changed any of the script from my local to live server. And the strangest thing is it is only this SESSION['cable'] variable I am having problems with even though all the SELECT field/SESSION variables are scripted the same way.
What would cause this particular SESSION variable to work on my local machine and not on the live server, when the other SESSIONS are working fine?
I have a form tool where users can select various SELECT fields to create a custom RF cable assembly. Each time a user selects a SELECT field value, the value is stored in a SESSION variable via the GET method. Here is one of my SELECT fields.
Code: Select all
<select class ="cabletype" name="cabletype" onChange="MM_jumpMenu('parent',this,0)">
<OPTION value="">----------</OPTION>
<?php
if (($series1=="IPX") || $series2=="IPX"){
while($cable= mysql_fetch_array($ipx_cables_result)) {
if ($cable['assembly'] == $cabletype) {
?>
<OPTION value="rf-cable-assemblies-test.php?cable=<?php echo $cable['assembly'];?>" SELECTED><?php echo $cable['cable_name'];?></OPTION>
<?php
} else {
?>
<OPTION value="rf-cable-assemblies-test.php?cable=<?php echo $cable['assembly'];?>"><?php echo $cable['cable_name'];?></OPTION>
<?php
}
}
} else {
?>
<?php
while($cable= mysql_fetch_array($cable_result)) {
if ($cable['assembly'] == $cabletype) {
?>
<OPTION value="rf-cable-assemblies-test.php?cable=<?php echo $cable['assembly'];?>" SELECTED><?php echo $cable['cable_name'];?></OPTION>
<?php
} else {
?>
<OPTION value="rf-cable-assemblies-test.php?cable=<?php echo $cable['assembly'];?>"><?php echo $cable['cable_name'];?></OPTION>
<?php
}
}
}
?>
Code: Select all
if((isset($_GET)) && !empty($_GET['cable'])) {
$_SESSION['cable']=$_GET['cable'];
$selected11=1;
} else{
$selected11=0;
}
//Setting the SESSION to a variable
$cabletype = $_SESSION['cable'];
What would cause this particular SESSION variable to work on my local machine and not on the live server, when the other SESSIONS are working fine?