aving serious problems with headers and session variables. Read related posts but none helped me.
I'm using sessions to store some info about the user logged in e.g. name, user_id, etc.
To start with, let's say $_SESSION['user_id']=6;
.
Then let's sat I want to view someone's profile. There is a dropdown list where you select the person whose profile you want to view, then click View. The processing page for this looks up for the user_id of the person you selected and redirects you to the person's profile.
The code is something like this:
<?php session_start();
$_SESSION['user_id']=1; //this is the user_id of the person logged in..
/*......many lines of code*/
?>
<select name="user_id">
<option value="4">George Thuo</option>
<!--other many options-->
</select>
<input type="submit" name="view" value="View">
Then this will direct you to the processing page which looks something like this:
$user_id=$_POST['user_id'];
header("Location: view.php?user_id=".$user_id);
See that before we used the header, $_SESSION['user_id']=1;
But after the header is user, I don't know why but $_SESSION['user_id']=4;(the user_id passed via the $_POST method
Why is it changing?