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 Developer web: http://robertbanh.com email: [email protected] phone: 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 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
