This is a discussion on Re: [PHP] $_SESSION problem within the PHP General forums, part of the PHP Programming Forums category; On Thu, Apr 10, 2008 at 4:29 PM, tedd <tedd.sperling@gmail.com> wrote: > Hi gang: &...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On Thu, Apr 10, 2008 at 4:29 PM, tedd <tedd.sperling@gmail.com> wrote:
> Hi gang: > > I'm stumped and in need of some expert explanation. > > I have prepared two demos (showing code) for your enjoyment: > > [1] http://www.webbytedd.com/x/index.php > [2] http://sperling.com/x/index.php > > Both of these demos have the exact same code; and are on the same server; > with exactly the same php-info -- so, why do they behave differently re > sessions? > > Note that [1] will retain the session values throughout the entire > session, while [2] does not and loses session values. as a sanity check have you dumped out the contents of the session after writing to it on [2] ? eg. <?php // .... $_SESSION['q6'] = ( isset($_SESSION['q6']) ? $_SESSION['q6'] : 0); $_SESSION['q7'] = ( isset($_SESSION['q7']) ? $_SESSION['q7'] : 0); $_SESSION['q8'] = ( isset($_SESSION['q8']) ? $_SESSION['q8'] : 0); $_SESSION['q9'] = ( isset($_SESSION['q9']) ? $_SESSION['q9'] : 0); var_dump($_SESSION); ?> also, doubtful or id assume youd mention it; but do you have .htaccess on either of the sites? you might just dump out the session component of the php config on each site to ensure theyre the same. -nathan |
|
|||
|
On Thu, Apr 10, 2008 at 5:05 PM, Nathan Nobbe <quickshiftin@gmail.com>
wrote: > On Thu, Apr 10, 2008 at 4:29 PM, tedd <tedd.sperling@gmail.com> wrote: > you might just dump out the session component of the php config on each > site to ensure theyre the same. > on that last note, this could be useful, <?php die(var_dump(ini_get_all('session'))); ?> -nathan |
|
|||
|
At 5:10 PM -0600 4/10/08, Nathan Nobbe wrote:
>On Thu, Apr 10, 2008 at 5:05 PM, Nathan Nobbe ><<mailto:quickshiftin@gmail.com>quickshiftin@gmai l.com> wrote: > >On Thu, Apr 10, 2008 at 4:29 PM, tedd ><<mailto:tedd.sperling@gmail.com>tedd.sperling@gm ail.com> wrote: > > you might just dump out the session component of the php config on >each site to ensure theyre the same. > > >on that last note, this could be useful, > ><?php >die(var_dump(ini_get_all('session'))); >?> > >-nathan They are identical -- and the same as shown in phpInfo, as I said. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com |
|
|||
|
At 5:05 PM -0600 4/10/08, Nathan Nobbe wrote:
>On Thu, Apr 10, 2008 at 4:29 PM, tedd ><<mailto:tedd.sperling@gmail.com>tedd.sperling@gm ail.com> wrote: > >Hi gang: > >I'm stumped and in need of some expert explanation. > >I have prepared two demos (showing code) for your enjoyment: > >[1] <http://www.webbytedd.com/x/index.php>http://www.webbytedd.com/x/index.php >[2] <http://sperling.com/x/index.php>http://sperling.com/x/index.php > >Both of these demos have the exact same code; and are on the same >server; with exactly the same php-info -- so, why do they behave >differently re sessions? > >Note that [1] will retain the session values throughout the entire >session, while [2] does not and loses session values. > > >as a sanity check have you dumped out the contents of the session >after writing to it on [2] ? >eg. > ><?php >// .... > $_SESSION['q6'] = ( isset($_SESSION['q6']) ? $_SESSION['q6'] : 0); > $_SESSION['q7'] = ( isset($_SESSION['q7']) ? $_SESSION['q7'] : 0); > > $_SESSION['q8'] = ( isset($_SESSION['q8']) ? $_SESSION['q8'] : 0); > $_SESSION['q9'] = ( isset($_SESSION['q9']) ? $_SESSION['q9'] : 0); >var_dump($_SESSION); > >?> > you might just dump out the session component of the php config on >each site to ensure theyre the same. > >-nathan Isn't that what the code is doing? I'm dumping the results in a print_r($_SESSION) -- isn't that he same thing? Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com |
|
|||
|
On Fri, Apr 11, 2008 at 6:30 AM, tedd <tedd.sperling@gmail.com> wrote:
> Isn't that what the code is doing? > > I'm dumping the results in a print_r($_SESSION) -- isn't that he same > thing? sorry tedd; obviously i was hasty to post. but i figured just looking for the obvious would be a good exercise as i cant count the times ive launched into an exhaustive search for the problem when its really something silly ive overlooked. that said; i know ur smart and you always post hard problems for 'the gang' ;) anyway, taking the cue from some of the other responses, have you looked at the page on session_write_close() ? http://us2.php.net/manual/en/functio...rite-close.php its kind of interesting; it looks like lots of people have run into issues using the location header to redirect clients to another script after a form submission. its never happened to me (knock on wood) but anyway some of the posts on that page may be worth reading. also, though it wont answer your question about why its happening, i was thinking you might alter the flow of ur scripts to see if you can get the same behavior on both sites. heres what i was thinking: add a hidden input to the form (from index.php) <input type="hidden" name="formsubmission" value="1" /> then after you call session_start() in index.php, have the following if(isset($_POST['formsubmission']) && $_POST['formsubmission'] == '1')) { include('part2.php'); // process form submission } then, make the following adjustments to part2.php remove the call to session_start() remove the call to header(location ... remove the call to exit() i think this will have the effect that the work flow is unaltered, but the organization of the logic on the back end will be different. effectively the call to header(location... will be removed so we would be able to tell if the issue is related to that. -nathan |