Is it possible to change a global variable from a hook and then display it in a widget?

I have a hook that is called every time a user edits the panel. This hook function will execute some code and then determine the value of a string, which I then want to be visible from a widget on the dashboard. Is it possible to “set” some global variable from a hook that could then be accessed from within a widget.php and passed into the corresponding widet-template.php?

EDIT: I have figured out that I can display $site variables from within widgets using panel()->site(), but I still am not sure how to change a $site variable from within a hook.

You can store site variables with the following:

site()->update(array(
  'myvariable' => 'myvalue'
));
1 Like

Worked perfectly, thanks!