Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

global php variables not saving after redirect

I am using a custom module in drupal. where in a function I have used $GLOBALS['dataCapsue'] = array("some", "data", "here"); And then did a drupal_goto redirect to another url of my custom module. When i re declare global variable as global $dataCapsule; in another function. It returns NULL. What may be the cause of this issue. Am I missing something?

Thanks

like image 343
JayKandari Avatar asked Oct 11 '25 14:10

JayKandari


2 Answers

Global variables are not persistent between http requests, like a redirect. You have to use a session to store this data between requests.

like image 120
Lorenz Meyer Avatar answered Oct 14 '25 03:10

Lorenz Meyer


Use a $_SESSION variable or a browser cookie to get the stored data on the other site.

like image 21
Biswajit Basak Avatar answered Oct 14 '25 04:10

Biswajit Basak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!