Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
global variable handling
  • Hello,

    I am trying to use variables available in all views of my application and thought set_global is the best method, isn't it ?

    I tried View::Set_global('test','test); like explained in the documentaiton and in some forum articles, and tried to write it everywhere like before function, or any controller. I can't find my variable $test in any view, I always have an error saying undefined vaiable.

    example :
    I set my global var in controller A methode action_index.
    I want to access to it in any view B dependent from controller B.

    There must be something I missed or don't understand, any idea ?


    Thanks for your help
  • HarroHarro
    Accepted Answer
    Yes, correct.

    PHP is stateless, so everything you do is within the scope of the request. Once that finishes PHP will forget everything. This is why you need a session to pass data from one request to the next.

    So controller B (assuming that is a second request from the browser) is unaware of other requests, it will not have access to data set in another request.
  • Thank you for your answer !
    I'll try that :)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion