esspea Posted February 1, 2023 Share Posted February 1, 2023 Hello all, So, from within a hook I can: Directly call a cookie variable by: $_COOKIE['varname'] and I can directly call server data by: $_SERVER['REMOTE_ADDR'] but $_SESSION['varname'] does not work, and neither does $session->get('varname'). How can I call a session variable from within a hook? Best regards, Snorri Link to comment Share on other sites More sharing options...
bernhard Posted February 1, 2023 Share Posted February 1, 2023 $session->foo = 'Foo!'; $wire->addHookBefore("Page::render", function ($event) { bd('hook fired'); bd($this->wire->session->foo); bd($this->wire()->session->foo); bd($event->wire->session->foo); bd($event->wire()->session->foo); bd($event->session->foo); bd($event->session->get('foo')); bd(wire()->session->foo); }); Choose whatever you like bist ? I prefer $this->wire->session->foo 2 2 Link to comment Share on other sites More sharing options...
esspea Posted February 2, 2023 Author Share Posted February 2, 2023 Thank you very much, bernhard, it works like a charm ? 1 Link to comment Share on other sites More sharing options...
bernhard Posted February 2, 2023 Share Posted February 2, 2023 1 hour ago, esspea said: it works like a charm ? Of course, it's ProcessWire ?? Just kidding - happy if it was helpful! ? 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now