2

I have created Custom checkout session in controller :

public function execute()
{
     $productData = $this->getRequest()->getPostValue();

     $this->_checkoutSession->setData("product", $productData);
     ...
     ...
}

And access that session in block but which close tab and open it again the lost its data. Even in few time session lost data.

Any suggestion ?

1

Use below code

public function __construct(........,\Magento\Backend\Model\Session $backendSession,......)
{
  $this->_session = $backendSession;
}

public function execute()
{
     $productData = $this->getRequest()->getPostValue();

     $this->_session->setData("product", $productData);
     ...
     ...
}

Hope it will work for you, for me working.

| improve this answer | |
  • I did same bro, that code mentioned in question also. – Ronak Chauhan May 19 '17 at 5:58
  • i did not use checkout session please check my code – Sunil Patel May 19 '17 at 6:00
  • Thanks for response but i tried all magento sessions – Ronak Chauhan May 19 '17 at 6:06
0

Facing the same issue. We are not getting order data or custom data from checkout session. This does not happen always but randomly. Please suggest what can be done.

| improve this answer | |
0

Instead of use Magento Checkout sessions I use php checkout:

$_SESSION['product'][$productData];

Because when I use magento session into block it destroy when I refresh.

| improve this answer | |
  • 1
    magento 2 does not allow to use that... when you submit module to marketplace it will show error, so better to use other – Sunil Patel May 19 '17 at 6:08

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.