magento 2.1 – The external file basket is empty when you use the browser's Back button

I have the following code in an external file (same domain) to get the details of the current basket, and I get all the details without any problem.

The problem is that when I go to the payment page using "Go to order" and I click on the back button of the browser, this basket is empty. I mean only on this external file.

When I click on "View and edit the cart" and I use the browser back button, the cart is in good condition.

Any help would be appreciated!

createApplication ("Magento  Framework  App  Http");
$ obj =  Magento  Framework  App  ObjectManager :: getInstance ();
$ obj-> get (Magento  Framework  App  State) -> setAreaCode (& # 39; frontend & # 39;);

$ storeManager = $ obj-> create ("\ Magento \ Store \ Model \ StoreManagerInterface");
$ storeManager-> setCurrentStore (1);

$ state = $ obj-> get (Magento  Framework  App  State & # 39;);

// Get dependencies for object managers
$ quote = $ obj-> get ('Magento  Checkout  Model  Session') -> getQuote ();
$ shoppingcart = $ obj-> get ( Magento  Checkout  Model  Cart & # 39;);

$ imagehelper = $ obj-> get ( Magento  Catalog  Helper  Image & nbsp;);

// Get the collection of quote and basket objects
$ quote = $ shoppingcart-> getQuote ();
$ quoteitems = $ quote-> getAllItems ();

// Get the cart
$ cart = $ shoppingcart-> getCart ();

// Obtain the basket subtotal
$ subtotal = number_format ($ quote-> getBaseSubtotal (), 2);
qty $ = 0;

$ arrProducts = array ();
$ mediaurl = $ storeManager-> getStore () -> getBaseUrl ( Magento  Framework  UrlInterface :: URL_TYPE_MEDIA);
$ baseurl = $ storeManager-> getStore () -> getBaseUrl ();

$ j = 0;
foreach ($ quoteitems as $ item)
{
$ arrProducts[$j]['productID']    = $ item-> getProductId ();
$ arrProducts[$j]['productName']    = $ item-> getName ();
$ arrProducts[$j]['productQty']    = $ item-> getQty ();
$ arrProducts[$j]['productPrice']    = number_format ($ item-> getPrice (), 2);

$ qty + = $ item-> getQty ();

$ _product = $ obj-> get (Magento  Catalog  Model  Product) -> load ($ item-> getProductId ());
$ arrProducts[$j]['productUrl']    = $ _product-> getUrlKey ();
$ arrProducts[$j]['productImage']    = $ mediaurl. & # 39; catalog / product & # 39; $ _ product-> getSmallImage ();

$ j ++;
}?> 

0 &&! Empty ($ arrProducts)) {?> Subtotal of the basket: $ Item (s) in the cart GO TO CAISSE <a href = "https://example.com// "> <img src =" http://magento.stackexchange.com/"/> <a href = "https://example.com// ">

$

Qty:
View and edit the cart
You have no items in your cart.