Don,

Thanks for the suggestion, I was doing something similar by just output the 
variables to the screen and checking that way. Unfortunately I couldn't 
pinpoint it to a particular line of code because it would be there on one page 
and gone at the top of the next page. I went into the code yesterday and 
confirmed I had session_write_close statements before each header("Location: ") 
command but was still experiencing the problem.

My code looked like:
session_write_close();
header("Location: nextpage.php");
exit;

I changed the quotes in the header redirect statements and explicitly set the 
exit code to 0 rather than implicitly on all pages and suddenly it started 
keeping the one cell from the array that it was losing. I'm at a loss as to why 
it was losing just one value out of a two arrays 
($_SESSION['Changes']['registration_id'] and 
$_SESSION['Original']['registration_id'] as well as 
$_SESSION['registration_id']) but none of the other 50 or so session variables. 
With this change everything currently appears to be working properly though. So 
I know I'll be writing redirect code in this manner from now on :)

Jeff

On Apr 29, 2011, at 8:51 AM, Don Lyckman wrote:

> I would try to pinpoint where the loss occurs by inserting some code
> that writes the session values to a file and put that code in page
> preceding where the loss occurs. Then run your app and check the file.
> Move the code around until you find exactly where the loss occurs.
> Hopefully at that point it will be easy to determine the cause.
> 
> It's a little tedious, but should work.
> 
> On Thursday, April 28, 2011, Jeffrey Bernier <[email protected]> wrote:
>> Rob,
>> I'm currently using PHP 5.2.15. Every page starts with an include to a file 
>> that sets up my database connections, some common variables for paths and 
>> starts the session.
>> The only thing I don't do is session_write_close immediately after the array 
>> as I'm setting various session variables though a series of if then else 
>> statements, but do have the session_write close at the bottom of those 
>> statements.
>> What gets me is it's losing one variable out of an 2 dimensional array but 
>> none of the others.
>> Thanks,
>> Jeff
>> 
>> On Apr 28, 2011, at 1:10 PM, Robert Banh wrote:
>> For PHP 5.3, it gets a little tricky...
>> 
>> 1. You need to have session_start() at the beginning of your php file, 
>> before any echo or HTML output.
>> 2. session_write_close() is required immediately after you set the array:
>> 
>> $_SESSION['blah'] = 'blah_value';
>> session_write_close();
>> 
>> Verify you have those 2 key pieces of information and it should work... if 
>> it doesn't, let me know if you're running PHP 5.2.x or 5.3.
>> 
>> Rob
>> 
>> 
>> On Thu, Apr 28, 2011 at 1:01 PM, Jeffrey Bernier <[email protected]> 
>> wrote:
>> 
>> Good afternoon everyone,
>> 
>> I'm hoping someone might be able to provide some insight to  an issue I'm 
>> having with session variables in PHP.
>> 
>> I have a number of session variables ($_SESSION['Changes']['var names'] and 
>> $_SESSION['Original']['var names'] are two examples) which contain a set of 
>> data loaded from a database and then used to check what changes a user makes 
>> during their session. Then before updating the database I run through a 
>> defined set of variables that are required to be sure those fields have 
>> values.
>> 
>> When I run through that script, the variable 
>> $_SESSION['Changes']['registration_id'] and $_SESSION['registration_id'] are 
>> both null but the other values within the array are there. I thought maybe 
>> it had something to do with the variable name of registration_id so I 
>> changed that to reg_id with the same results. I've been though every page 
>> that the user walks through in the process and verified that I have a 
>> session_start() before I use the session variables and I have a 
>> session_write_close() before each redirect to be sure the session data is 
>> updated.
>> 
>> The really strange part is that the variable 
>> $_SESSION['Changes']['registration_id'] is only created on the first page 
>> that the user visits and then only on the first visit to that page. The 
>> following pages all have access to that variable until I get to my review 
>> page where I test my variables. I have dumped the array and everything else 
>> is there as expected except that those variables. I've searched the code and 
>> this is the only place that the variable is assigned.
>> 
>> I'm using PHP 5 though I saw the same behavior with PHP 4 before upgrading 
>> to a new server.
>> 
>> Anyone have any thoughts regarding how two or three session variables could 
>> be reset to Null from one page to the next?
>> 
>> Thanks,
>> 
>> Jeff
>> 
>> --
>> Our Web site: http://www.RefreshAustin.org/
>> 
>> You received this message because you are subscribed to the Google Groups 
>> "Refresh Austin" group.
>> 
>> [ Posting ]
>> To post to this group, send email to [email protected]
>> Job-related postings should follow http://tr.im/refreshaustinjobspolicy
>> We do not accept job posts from recruiters.
>> 
>> [ Unsubscribe ]
>> To unsubscribe from this group, send email to 
>> [email protected]
>> 
>> [ More Info ]
>> For more options, visit this group at 
>> http://groups.google.com/group/Refresh-Austin
>> 
>> 
>> --
>> Robert Banh | Web Developerweb: http://robertbanh.com 
>> <http://robertbanh.com/>
>> email: [email protected]: 512.698.6072
>> 
>> 
>> 
>> --
>> Our Web site: http://www.RefreshAustin.org/
>> 
>> You received this message because you are subscribed to the Google Groups 
>> "Refresh Austin" group.
>> 
>> [ Posting ]
>> To post to this group, send email to [email protected]
>> Job-related postings should follow http://tr.im/refreshaustinjobspolicy
>> We do not accep
>> 
>> 
>> 
>> --
>> Our Web site: http://www.RefreshAustin.org/
>> 
>> You received this message because you are subscribed to the Google Groups 
>> "Refresh Austin" group.
>> 
>> [ Posting ]
>> To post to this group, send email to [email protected]
>> Job-related postings should follow http://tr.im/refreshaustinjobspolicy
>> We do not accept job posts from recruiters.
>> 
>> [ Unsubscribe ]
>> To unsubscribe from this group, send email to 
>> [email protected]
>> 
>> [ More Info ]
>> For more options, visit this group at 
>> http://groups.google.com/group/Refresh-Austin
>> 
> 
> -- 
> Our Web site: http://www.RefreshAustin.org/
> 
> You received this message because you are subscribed to the Google Groups 
> "Refresh Austin" group.
> 
> [ Posting ]
> To post to this group, send email to [email protected]
> Job-related postings should follow http://tr.im/refreshaustinjobspolicy
> We do not accept job posts from recruiters.
> 
> [ Unsubscribe ]
> To unsubscribe from this group, send email to 
> [email protected]
> 
> [ More Info ]
> For more options, visit this group at 
> http://groups.google.com/group/Refresh-Austin

-- 
Our Web site: http://www.RefreshAustin.org/

You received this message because you are subscribed to the Google Groups 
"Refresh Austin" group.

[ Posting ]
To post to this group, send email to [email protected]
Job-related postings should follow http://tr.im/refreshaustinjobspolicy
We do not accept job posts from recruiters.

[ Unsubscribe ]
To unsubscribe from this group, send email to 
[email protected]

[ More Info ]
For more options, visit this group at 
http://groups.google.com/group/Refresh-Austin

Reply via email to