| Luis Cruz
                                                                                                                             
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Thursday 12 October 2006 2:28:26 pm 
                                                                
                                                                 Here is the situation; I have an extension that uses the PEAR::HTML_Quickform package. When the form submits, it submits to itself and calls functions to perform input validation and process the data. In my data processing function, I attempt to set some session variables and depending on what happens redirect to another extension. However, when I arrive at the second extension, the session variables I have set have disappeared. I've checked the session ID, and it does not change between the form and the extension you get redirected to. Prior to the redirect, a dump of the $_SESSION variable shows that the information is set. But, you get to the next page and the $_SESSION variable dump shows the information is gone. I have tried a number of methods to set the variables and redirect to the page. A skeleton of my extension is below; I'll add in the various methods I have tried. No clue as to why this is happening. Using eZ 3.6.3, PHP 4.3.9. 
<?php
/**
 * Include Exponential libraries and set necessary module variables 
 */
include_once("kernel/common/template.php");
include_once( "lib/ezutils/classes/ezuri.php" );
include_once( "lib/ezutils/classes/ezhttptool.php" );
$eZURI =& eZURI::instance();
$userParameters = $eZURI->userParameters();
$http =& eZHTTPTool::instance();
$Module =& $Params["Module"];
$Module->setTitle("View");
/**
 * Include libraries and set necessary variables
 */
$directoryLevel = "/path/to/classes/";
require_once($directoryLevel . "class/Foo.php");
/**
 * Form processing functions
 */
function doSomething($formData)
{
    // Method 1:  failure
    $_SESSION["stuff"] =& $stuff;
    header("Location:  /path/to/somewhere\r\n");
    exit();
    // Method 2:  failure
    $http =& eZHTTPTool::instance();
    $http->setSessionVariable("stuff", $stuff);
    $http->redirect("/path/to/somewhere");
    // Method 3:  failure
    $http =& eZHTTPTool::instance();
    $http->setSessionVariable("stuff", $stuff);
    header("Location:  /license/upgrade\r\n");
    exit();
    // Method 4:  failure
    $_SESSION["stuff"] =& $stuff;
    eZSessionStop();
    header("Location:  /path/to/somewhere\r\n");
    exit();
    // Method 5:  failure
    $http =& eZHTTPTool::instance();
    $http->setSessionVariable("stuff", $stuff);
    eZSessionStop();
    $http->redirect("/path/to/somewhere");
    // What will bring success?!
}
/**
 * Build the form
 */
$defaultInfo = array(
    );
// Create the form
$form =& new HTML_QuickForm("form", "post", $_SERVER["REQUEST_URI"], "_self", "", true);
$result = "";
// If the form validates, process the data.
if ($form>validate()) {
    $result = $form->process("doSomething", false);
}
// Create the Exponential template
$tpl =& templateInit();
$tpl->setVariable("module", $Module );
$tpl->setVariable("text", $text);
// Set the Exponential template variables
$Result = array();
$Result["content"] =& $tpl->fetch("design:license/Exponential.tpl");
$Result["path"] = array
    (
    array
        (
        "url"   => "/view",
        "text"  => "View"
        )
    );
?>
 | 
                                                
                                                                                                                                                        
                                                        | Kristof Coomans
                                                                                                                             | Friday 13 October 2006 12:37:30 am 
                                                                 Hello Luis Did you try this? 
// Method 6
$http =& eZHTTPTool::instance();
$http->setSessionVariable( 'stuff', $stuff );
return $Module->redirectTo( '/path/to/somewhere' );
 I advice you to upgrade to a more recent release of the 3.6 branch, the one you are using is really old. independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org
                                                                 | 
                                                                                                    
                                                        | Luis Cruz
                                                                                                                             | Friday 13 October 2006 6:36:42 am 
                                                                 @Kristof Nope, that didn't work either. The other methods redirected to the second extension, but this one didn't even do that. Thanks though; I'll look into the code for the module redirect and see if there is something else in or around it that might be useful to try. Cheers. | 
                                                                                                    
                                                        | Luis Cruz
                                                                                                                             | Wednesday 01 November 2006 10:20:22 am 
                                                                 Upgrading to the latest version of eZ turned out to not be the solution to my problem (now on 3.6.11). I was misunderstanding how eZ was handling session information; this helped me clear up one issue. However, my primary issue remains. Here is the flow step by step. 1. End up on page /foo. This page contains a form. 2. Plug in values into the form and submit. 3. The form submits to the same page, /foo. 4. /foo detects that the form has been submitted and calls function validate() 5. Based on the form data, validate() sets certain session variables. 6. validate() finally does a header("Location: /bar"); 7. Arriving at /bar shows that the session variables have vanished. I've put debug statements nearly everywhere. In between steps 5 & 6, I dump out the entire $_SESSION variable to a log file. It shows that my variables are set. However, dumping $_SESSION out on step 7 shows that the variables set in the validate() function on /foo have disappeared. I've also tried placing eZSessionStop() calls in various places (e.g., after setting my variables in validate() ) to flush things out, but that has not brought success either. Very stumped at this point. |