saseow
Posts: 744
|
Posted: 03/18/2013, 11:02 AM |
|
I have a menu item that calls a page where a lot of calculations are done. This page in turn calls the rpt_profit_loss.php page. Before the redirect I store a session var called 'pl_labor'. Echoing the var in the first page shows that it is set however, the second page gets a 0 for the var unless I click the menu item a second time.
$Component->SetValue(CCGetSession("grand_tot"));
if (CCGetParam("calc") == 1)
{
CCSetSession("pl_labor",CCGetSession("grand_tot"));
header("Location: rpt_profit_loss.php");
exit;
}
CCSetSession("grand_tot","");
Any ideas from anyone?
|
|
|
MichaelMcDonald
Posts: 640
|
Posted: 03/19/2013, 9:16 AM |
|
It shouldn't make any difference but try using
global $Redirect;
$Redirect = "rpt_profit_loss.php";
and see how it goes...
also, just noticed the exit;
Whats that for?
_________________
Central Coast, NSW, Australia.
|
|
|
saseow
Posts: 744
|
Posted: 03/19/2013, 9:26 AM |
|
Well, all the coding was OK including the 'exit'.
The problem was that the component was at the bottom of a report in the footer section and when the page was rendered, the 'beforeshow' of the component gets called more than once so it was redirecting with no value in the var.
To get around this I added a condition that the var to pass should not be 0.
Works fine now.
|
|
|
DataDoIT
|
Posted: 03/19/2013, 12:06 PM |
|
When using the header() function, you should always follow it with an
exit since you're sending new header information and you don't want the
current headers to process.
You should get a PHP error if you use the header() function in a CCS
event without an immediate exit.
Look in Common.php, and you will see that the CCS Redirect routine is
really a nice way of saying header(); exit;
|
|
|
|