doug_mize
Posts: 12
|
| Posted: 04/09/2008, 6:34 PM |
|
Hello!
Stupid question:
Where in CCS do I define variables for use throughout a session? I need to pull a user# from a cookie and make it into a variable called $user so that I can use that in other functions and on other pages.
Also, I need to set a variable called $custom_list_name when a user inputs their custom list name into, and submits, my php form.
I've got the list name form working fine, in that it writes the proper record to the proper table, but I need the list name value as a variable ($custom_list_name) for use on other pages as well.
Any help would be great!
Doug
|
 |
 |
CCT
Posts: 44
|
| Posted: 04/10/2008, 11:15 AM |
|
Hello, Doug.
In your case, I'd just directly use $_SESSION array. This array is already superglobal, so you won't need to declare your custom variable in every function, just write $_SESSION['user'] or $_SESSION['custom_list_name']. You'll just once assign that session variables from user form (seems like Record's "AfterInsert/AfterUpdate" event is good place for this).
Instead of working with $_SESSION directly, you can also use CCGetSession/CCSetSession functions.
Best regards,
Frank.
_________________
Get more CodeCharge Studio builders at http://codechargetools.com |
 |
 |
calfaro
Posts: 6
|
| Posted: 06/17/2008, 8:00 PM |
|
Is there another way to do this? I need to declare a variable inside a grid as custom code and then be able to access it somewhere else on the page outside the grid. I guess session would work, but I don't really need it for the whole session, only for a single php script.
|
 |
 |
wkempees
Posts: 1679
|
| Posted: 06/18/2008, 4:07 AM |
|
Page AfterInitialize, declare the variable either in Code or through Action Declare variable.
Any where you want to use it (display or alter it) either use Code or Action.
In Short: (declaring a var DeKemp set it initaly to 123.
Page AfterInitialize:
global $DeKemp;
$DeKemp = 123;
Any other event :
global $DeKemp;
echo $DeKemp;
$DeKemp +- 8;
and so on.
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
|