Forum Moderators: coopster
<?php
session_start()
$thisuser = $_SESSION['uid'];
$thiscustomer = $_SESSION['cid'];
session_write_close();
?>
I'm using print_r to print the array for debugging.
I have script "abc.php" which displays page that allows users to select filter criteria for a search. This call a script "def.php" that is just a frameset with sources of scripts "view.php" and "edit.php". Another that edits the records. Everything works as expected. "view.php" and "edit.php" call the session variables with the above code and grab relavent information. "view.php" has a link that's built for each record to feed it to the "edit.php" script, i.e.:
echo "<TD><A href=\"fileedit.php?fileid=" . $query_data[fileid] . "&thisjob=" . $jobid . "\" target=\"fileediter\">" . $query_data['fileident'] . "</A></TD>";
This works great. .... However ... way back in script "abc.php" there is a pulldown input;
<select name="cfilter">
<option value="0">Any</option>
<option value="1" selected>A Test Company</option>
<option value="2">City Stamp Works</option>
<option value="3">Unicorr Packaging Group</option>
<option value="4">Timbar</option>
</select>
When I click the above link in "view.php" the value of $_SESSION['cid'] is changed to whatever the current value of the $cfilter from the above pulldown in "abc.php". All other $_SESSION vars stay the same like they should. Between all 4 scripts the only time a session is open is exactly what I have at the beginning of this postand they are at the top of each script before any whitespace.
Reproducable but inexplicable.
It seems that the session variable is being reset at some point within your code. This may be the problem: Each of your pages have
<?php
session_start()
$thisuser = $_SESSION['uid'];
$thiscustomer = $_SESSION['cid'];
session_write_close();
?>
this at the beginning. Once the session variables are set, then you only need to type
session_start();
at the beginning of the page to retreive those variables. Instead, you are resetting those variables to potentially different values.
Hope this helps!
eelix
When you say "set by accident" what do you mean here?
I would think there would have to be some sort of ;
session_start()
$_SESSION['cid'] = 5;
I get a little quesy when I think that a variable can just "take a value" at random whether it's a session variable or any other. Unless there is some other method/function/process that writes to session variables, there are no other lines that even reference the session other than what I've shown. The login script is the only one that ever sets the session variable. Every other script has only those first three lines. I'm still absolutely puzzled as to why it would happen when that link is clicked. And, why would it consistantly pick up the value of $cfilter?
Thanks for all the help folks.