Reputation: 1839
Array
( [step1] => 1
[step2] => 18
[step3] => 2000
[step4] => Array ( [crdStat] => step3-slctcrdtcrd )
[step5] => Array([cardName] => Test )
[step6] => Array([mnthSpend] => 1000 )
[step7] => Array ([payFrq] => undefined )
[step8] => Array([rolAmnt] => 344 )
Currently I am Just assigning that in PHP way
$_SESSION['mcwizard'][$step]['bTransStat'] = $_GET['bTransStat'];
I want to save this array in a session in Drupal 7 What is the best Drupal 7 way to achieve this. So I can use these session variable anywhere in the application.
Thank You
Upvotes: 0
Views: 1789
Reputation: 774
The way you are doing it is correct (to store a variable in a session variable), but if it's to be called for all the pages in Drupal, use one of the following two hooks:
1)hook_init()
2)hook_boot()
Upvotes: 1
Reputation: 1004
There isn't really a Drupal way to set session variables, outside of the regular $_SESSION global. You should however be careful when choosing where to place it. If you're placing it in a Hook you need to make sure that the hook won't be cached and will always be called, otherwise your variables won't get updated every time and might be out of date. Hope this helped, sorry there isn't a Drupal way of doing this!
Upvotes: 1