maxhugen
Posts: 272
|
| Posted: 04/08/2008, 8:34 PM |
|
I'm trying to set a session variable as per the example in the docs "Create Custom Session Variables" when a user logs in, but I'm getting a script error (syntax error) when I try to view the page.
The error is reported as being at line 58, which is in the function bind_events():
addEventHandler("LoginButton_DoLogin", "click", LoginButton_DoLogin_OnClick);
The actual error, however, is in the custom code which I copied and modified from the Docs:
//LoginButton_DoLogin_OnClick @8-B2A5A68D
function LoginButton_DoLogin_OnClick()
{
var result;
//End LoginButton_DoLogin_OnClick
//Custom Code @95-2A29BDB7
if ($LoginButton_DoLogin_OnClick == true) {
$db = new clsDBConnection1();
CCSetSession("FName", CCDLookUp("FName","Person","PersonID=".$db->ToSQL(CCGetUserID(),ccsInteger), $db) );
$db->close();
}
//End Custom Code
//Close LoginButton_DoLogin_OnClick @8-BC33A33A
return result;
}
//End Close LoginButton_DoLogin_OnClick
Can anyone suggest what I'm doing wrong?
MTIA
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
maxhugen
Posts: 272
|
| Posted: 04/08/2008, 9:41 PM |
|
Maybe coz I tried to insert this on the Client side, should be in Server side?
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
maxhugen
Posts: 272
|
| Posted: 04/08/2008, 11:06 PM |
|
Have worked out that the code to set a session variable should be in the Server-side script, but still struggling.
function Login_Button_DoLogin_OnClick(& $sender)
{
... CCS code ...
//Custom Code @95-2A29BDB7
function Login_DoLogin_OnClick(& $sender) {
if ($Login_DoLogin_OnClick == true) {
//$db = new clsDBConnection1();
//$db = new DBEIP_MySQL();
$db = new clsDBEIP_MySQL();
global $DebugOutput;
echo $DebugOutput->CCGetUserID();
echo $DebugOutput->CCDLookUp("FName","Person","PersonID=".$db->ToSQL(CCGetUserID(),ccsInteger), $db);
CCSetSession("FName", CCDLookUp("FName","Person","PersonID=".$db->ToSQL(CCGetUserID(),ccsInteger), $db) );
$db->close();
}
}
//End Custom Code
... CCS code ...
}
From examining CCS-generated code on other pages, I think that "$db = new clsDBEIP_MySQL();" is now correct (my connection is named EIP_MySQL)...
Unfortunately, I don't know where the 'echo' command actually outputs to, so I can't determine if my connection and CCDLookup is working or not. Wish CCS had a debugger.
The only way I can say it's not working is because in another page (where the login page redirects to) I have a Label, with the DefaultValue set to CCGetSession('FName','NOT SET!').
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
maxhugen
Posts: 272
|
| Posted: 04/09/2008, 5:51 PM |
|
Finally worked it out:
function Login_Button_DoLogin_OnClick(& $sender)
{
... CCS code ...
//Custom Code @95-2A29BDB7
if ($Login_Button_DoLogin_OnClick == true) {
$db = new clsDBEIP_MySQL();
CCSetSession("FName", CCDLookUp("FName","Person","PersonID=".$db->ToSQL(CCGetUserID(),ccsInteger), $db) );
$db->close();
}
//End Custom Code
... CCS code ...
}
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com |
 |
 |
|