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