CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Session Var not set when Redirecting (Solved)

Print topic Send  topic

Author Message
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?
View profile  Send private message
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.

View profile  Send private message
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.
View profile  Send private message
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;

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.