After updating from 2.3.5 to 2.4.4-p2 I am getting an error when the frontend loads. This is how it looks, when I load the frontend: https://i.stack.imgur.com/L1liN.png

The admin works just fine and there are no errors during cimpilation, upgrade or deployment. Any idea how to solve this? The error in the logs is: Error: Call to a member function getCookieSecure() on null in /vendor/magento/module-theme/view/frontend/templates/js/cookie.phtml:21

The code on line 21 is this:

"secure": <?= $block->getSessionConfig()->getCookieSecure() ? 'true' : 'false'; ?>,

It seems getSessionConfig returns null.

Running on PHP 8.1


  • 1
    Some checks you can do: is your custom theme overriding that template? do you have some third party module which could be involved here? try disabling one by one Oct 24, 2022 at 10:00

1 Answer 1


Somewhere in your layout you (or an extension) have the following definition:

<block class="Magento\Framework\View\Element\Js\Cookie" name="js_cookies" template="Magento_Theme::js/cookie.phtml"/>

However, since Magento 2.4.4 (or maybe even sooner) this needs to be updated to

<block class="Magento\Framework\View\Element\Js\Cookie" name="js_cookies" template="Magento_Theme::js/cookie.phtml">
        <argument name="session_config" xsi:type="object">Magento\Theme\ViewModel\Block\SessionConfig</argument>

otherwise $block->getSessionConfig() in the cookie.phtml template will be null.

  • 1
    This is the fix! In my case it was in the child theme I created in app/design
    – P. Sopacua
    Nov 8, 2022 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.