i am trying to create a plugin for class Magento\Framework\App\Response\Http for beforeSendResponse and do some actions like session setter.. but it did not work as expected.
The code run several times after i cleared page cache. But after all, the code did not run any more. Even i write die(); in Magento\Framework\HTTP\PhpEnvironment\Response->sendReponse()(Magento\Framework\App\Response\Http extends this class) and nothing happend.
My code:
etc/frontend/di.xml
<type name="Magento\Framework\App\Response\Http">
<plugin name="setCookieForUser" type="Example\Module\Plugin\HttpSetCookie"/>
</type>
Plugin/HttpSetCookie.php
namespace Example\Module\Plugin;
class HttpSetCookie {
public function beforeSendResponse(
\Magento\Framework\App\Response\Http $subject
) {
// do set cookie
}
}
i also configured varnish for my site. That is varnish problem? Can anyone please let me know why? How i solve this issue?