1

I am going to add Age verification block on Home page. for that i want to set session or cookie variable. so that i can check it through out all pages of store weather age verification session or cookie set or not.

0

You can use the below classess to set cookie and session in your block by passing into dependency.

Magento\Framework\Session\SessionManagerInterface;

Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;

Magento\Framework\Stdlib\Cookie\PublicCookieMetadata;

Magento\Framework\Stdlib\CookieManagerInterface;

For reference link

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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