CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> Archive -> GotoCode Archive

 Retrieving Session Parameter problem

Print topic Send  topic

Author Message
Mark
Posted: 07/07/2002, 8:27 AM

PHP & MySQL - CCS v1

Hi,

how many session parameters can be available at any one time?
My reason for asking is that I only seem able to retrieve the last one set !

In page 1, I have this code -

function user_AfterInsert() { //user_AfterInsert @2-AD8D0A3D

//Custom Code @54-2A29BDB7
// -------------------------
//set a session variable to contain the value of autoincrement key for user record
$newone = mysql_insert_id();
CCSetSession($NewUserId, $newone);
// -------------------------
//End Custom Code

} //Close user_AfterInsert @2-FCB6E20C

In Page 2, called from Page 1, I have a field called "UserID", whose default value is - CCGetSession($NewUserId)

It works fine.

In page 2, I have similar code in the After Insert event to set a session parameter called $NewAdId.

In Page 3, called from Page 2 , I have two fields on a form that default to the above two session parameters, just in the same way that the field on Page 2 defaults.

But this time, both fields have the value of the second session parameter set - $NewAdId.

If I remove the default value for the field that should be set to $NewAdId, the other field, which should contain the value for $NewUserId, doesn't - it still defaults to the value for $NewAdId....

As far as I can see, the first session parameter is being over-written by the setting of the second !

Any ideas - this is driving me crazy !!

Thanks,
Mark
Chris K.
Posted: 07/07/2002, 11:22 AM

They syntax for using CCSetSession is:

CCSetSession(<variable name>, <value>)

You give *name* of the variable (as string), not variable itself. You should use:

$newone = mysql_insert_id();
CCSetSession("NewUserId", $newone);

The described behavior happens because both your variables have empty values and you set and retrieve session variable with empty name.
Mark
Posted: 07/07/2002, 12:39 PM

Thanks Chris,

I'll give it a try !

Regards,
Mark
Mark
Posted: 07/07/2002, 12:48 PM

Hi Chris,

tried it & it doesn't work - I don't even pick up the first variable on Page 2 any more...

I've also tried changing the common.php file as per another thread, by removing the curly braces & extra $ sign from param_name on the two lines marked ** -

function CCSetSession($param_name, $param_value)
{
global ${$param_name}; **
if(session_is_registered($param_name))
session_unregister($param_name);
${$param_name} = $param_value; **
session_register($param_name);
}

But this makes no difference.
In fact if I go back to using CCSetSession($NewUserId ...) and make the above change to common.php, then it doesn't work then either.

Any ideas ?

Thanks,
Mark
Chris K.
Posted: 07/07/2002, 1:17 PM

Check you have register_globals setting turned on (it is off by default in the latest PHP releases). Or use $HTTP_SESSION_VARS array alternatively:

to set session variable:
$HTTP_SESSION_VARS["variable"]=<value>;

to get session variable:
$value=$HTTP_SESSION_VARS["variable"];

PHP session handling will be fixed in next CCS release.

   


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

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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