Re: Session Array Disappears

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm thinking the guy who suggested ignore_user_abort(TRUE) is just
doing Voodoo Programming :-)

It may or may not be something you want, but I doubt it will have any
affect whatsoever on your posted problem.

Actually, I think anywhere that somebody thinks they need
ignore_user_abort, they probably should re-structure the application
to handle the long-running process in a cron job or some other
asynchronous manner, rather than try to keep a script running tied to
an HTTP connection that isn't useful anymore.

In other words:  Move the long-running slow heavy lifting computation
OUT of the web page generation part, so that your user gets a web page
super fast in the first place, and so the long-running part can get
done later, when the user isn't stuck waiting around for it.

Your basic Human Interface principle, which is apparently going to be
called Web 2.0 now. :-)

On Mon, April 24, 2006 9:09 pm, Webmaster wrote:
> Hello,
>
> Thank you for the reply.
>
> Interesting function.  I have not heard of that one previously.  I've
> read the manual pages for it.....If I understand
> ignore_user_abort(TRUE)...you are thinking that maybe the user is
> being
> disconnected (using stop button or having ISP issues) prior to the
> script finishing and therefore the script does not have a chance to
> create the array?  I'm wondering if that would be true, since later in
> the same script, it generates an email to inform me someone's
> submission
> was lost because the array did not exist.  I'm confused how it could
> stop executing the middle of the script (step 4a and 5 below) but yet
> execute the end of the script (the final step in the code below)?  I
> was
> first made aware of this issue because of the email, so I think the
> end
> of the script is executing.
>
> Thanks,
> R
>
> Al wrote:
>> add a ignore_user_abort(TRUE) first thing in your code.
>>>>> Hello,
>>>>>
>>>>> The site I'm working on works like this...
>>>>> Requires a login that uses sessions to remember username and
>>>>> email
>>>>> address.  Upon being verified, the user is presented with a page
>>>>> that displays several questions regarding their background.  Upon
>>>>> submitting the background page, a script checks to make sure all
>>>>> background questions were answered.  If not, the page is
>>>>> redisplayed with a warning to answer all questions.  If they are
>>>>> all present, a second page is displayed asking about a specific
>>>>> topic.  Submitting the second page calls up the code provided
>>>>> below.
>>>>>
>>>>> In reading the www.php.net/manual/en/ref.session.php page, I'd
>>>>> like
>>>>> to point out we do not use cookies.  The session id is propagated
>>>>> in the URL (although it's not visible in the URL bar).  Also,
>>>>> session.gc_maxlifetime is set to 5400.  We are using PHP 4.3.4.
>>>>>
>>>>> Not very often, but once in a while, I'll get an email warning me
>>>>> that a submission was denied because $_SESSION['Q'] is empty.
>>>>> I'm
>>>>> wondering, hoping and/or praying that someone out there can look
>>>>> at
>>>>> this small script and let me know if I'm doing something wrong
>>>>> with
>>>>> the built in function array_pop, perhaps I don't understand
>>>>> sessions at all or perhaps it is a server issue.  It's very
>>>>> confusing because other session variables (name and email from
>>>>> the
>>>>> login page) are not emptied, just $_SESSION['Q'].
>>>>>
>>>>> Here's my code with some documentation:
>>>>> <?php
>>>>> /*
>>>>> $_SESSION['startQA'] contains 11 elements and is generated by a
>>>>> previous page in the site.
>>>>> Once the visitor clicks the page two submit button, the above
>>>>> SESSION variable comes into play again.
>>>>>
>>>>> This script takes that array of elements and does the following:
>>>>> 1. Assign session array to local array
>>>>> 2. Removes the last elemental value using array_pop
>>>>> 3. Removes the last elemental value using array_pop
>>>>> 4. Assign local variable the value of the a POST element
>>>>> 4a. Create a new session array and populates the first element
>>>>> equal to POST element
>>>>> 5. Runs through and populates the remaining 9 elements
>>>>> 5a. Total of 10 elements are now populated, 0 thru 9
>>>>> 6. Double checks the existence of each element
>>>>> 6a. if an element is missing, email me a warning and end program
>>>>> */
>>>>>
>>>>> //Assign Session array to local variable
>>>>> // Step 1
>>>>> $thisQarray = $_SESSION['startQA'];
>>>>>
>>>>> //Remove the last element of the original array
>>>>> // Step 2
>>>>> $area = array_pop($thisQarray);
>>>>>
>>>>> //Remove last element of bgq array and assign to taking_test_at
>>>>> // Step 3
>>>>> $from_location = array_pop($thisQarray);
>>>>>
>>>>> //Assign test version to variable
>>>>> // Step 4
>>>>> $testVersion = $_POST['version'];
>>>>>
>>>>> //Start building the final Session Array
>>>>> // Step 4a
>>>>> $_SESSION['Q'] = array($testVersion);
>>>>>
>>>>> //Populate rest of Session Array
>>>>> // Step 5
>>>>> for ($newBGQCounter=0; $newBGQCounter<count($thisQarray);
>>>>> $newBGQCounter++)
>>>>> {
>>>>>   $_SESSION['Q'][$newBGQCounter+1] = $thisQarray[$newBGQCounter];
>>>>> }
>>>>>
>>>>> //test for existense of session array elements
>>>>> if ( ($_SESSION['Q'][0] == "") OR ($_SESSION['Q'][1] == "") OR
>>>>> ($_SESSION['Q'][2] == "") OR ($_SESSION['Q'][3] == "") OR
>>>>> ($_SESSION['Q'][4] == "") OR ($_SESSION['Q'][5] == "") OR
>>>>> ($_SESSION['Q'][6] == "") OR ($_SESSION['Q'][7] == "") OR
>>>>> ($_SESSION['Q'][8] == "") OR ($_SESSION['Q'][9] == "") )
>>>>> {
>>>>>   SEND ME AN ERROR EMAIL
>>>>>   END PROGRAM
>>>>> }
>>>>> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux