Hot answers tagged

95 votes
Accepted

Magento 2 backend session timeout

Stores > Settings > Configuration > Advanced > Admin > Security > Admin Session Lifetime (seconds) Also, there is a possibility to set this parameter directly to the database, just put a value ...
user avatar
55 votes

"invalid form key. please refresh the page" - cannot login to admin panel

It also happens if the cookie domain in System > Configuration > Web > Cookies is different from the actual site domain. To remove the setting without access to the admin panel: use the following ...
user avatar
38 votes

SOLVED - Magento 2 - Unable to login to admin (no error message) stuck at login screen

Emergency Fix Whether or not this solution works, please try these steps first. You WILL be able to login which means you are on the right page. If you still could not login, your issue is most ...
user avatar
34 votes

Magento 2 - How to get all items in cart?

I'll answer the question in two parts: I. Where should you change the checkout URL? The destination in link.phtml is $block->getCheckoutUrl(). You should not change the template to change ...
user avatar
29 votes

Magento 2 - How to get all items in cart?

The use of Magento\Checkout\Model\Cart is deprecated. You should use the session to get the quote and your cart items. use Magento\Checkout\Model\Session; public function __construct( ... ...
user avatar
  • 1,094
27 votes
Accepted

Session validation failure in Magento 1 EE v 1.14.3.x (and CE 1.9.3.x)

After some advanced debugging, session tracing and thinking about all that magic I was able to reproduce the problem and understand the reason for it. I prepared a little timing illustration, you can ...
user avatar
26 votes
Accepted

How to remove SID (session ID) from URL in Magento 2

Go to the Store > Configuration > General > Web > Session Validation Settings > Use SID on Storefront and set its value to No Here is the good answer about the SID: The SID is a "session ID". ...
user avatar
25 votes
Accepted

Understanding Magento Registry

The registry stores data to memory which is specific to that request (rather than user or anything else), and persists for the duration of that request only. The principle is very simple really, the ...
user avatar
23 votes
Accepted

Magento 2: Where is cart data saved?

Magento2, save cart details at Quote tables. For Cart general details use quote table . Carts item details at quote_item. Cart items option details at quote_item_option Additional: Checkout ...
user avatar
  • 75.8k
22 votes
Accepted

customer session does not work except customer page - Magento 2

To have access to real data in Magento 2 session you have to apply one of the following Do it on non-cacheable page. Disable full page cache. Set $this->$_isScopePrivate = true for block where ...
user avatar
20 votes
Accepted

What's the correct cookie config for a Magento site split across multiple instances as subdomains?

We had to do something similar recently: Cookie Path: / Cookie Domain: .site.com That did the trick in our case.
user avatar
20 votes

Magento 2 backend session timeout

Check attached image screenshot for better understanding of admin process. Go to Stores->Settings->Configuration->Advanced->Admin->Security->Admin Session Lifetime (seconds) And check screenshot.
user avatar
19 votes
Accepted

"invalid form key. please refresh the page" - cannot login to admin panel

I am posting the question / answer because I couldn't find anything relevant. The issue was that the drive on which my magento installation resides was full. I freed up some room, clear the /var/...
user avatar
  • 5,169
18 votes

Magento 2 - How to get all items in cart?

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $cart = $objectManager->get('\Magento\Checkout\Model\Cart'); // retrieve quote items collection $itemsCollection = $cart->...
user avatar
  • 1,069
16 votes
Accepted

Magento 2.1 admin logged in issue in session

To disable this feature go to Stores > Configuration > Advance > Admin > Security and change value of Admin Account Sharing to Yes.
user avatar
15 votes

Magento 2: Syncing Backend and Frontend State/Cache

Magento 2 uses Customer Data JS API to represent user session data in browser. All JS widgets are supposed to retrieve customer data from Customer Data JS API. Customer Data is split to sections (cart,...
user avatar
  • 4,446
14 votes
Accepted

When does Magento use sessions and when cookies?

No, that means that sessions are persisted with a cookie, which contains the ID of the session. The only alternative in PHP is a URL parameter like ?SID=d41d8cd98f00b204e9800998ecf8427e where ...
user avatar
12 votes
Accepted

Magento session storage: Redis vs. Memcached

As per as my concept Redis is most good: Memcached is Free & open source, in-memory key-value store, high-performance, distributed memory object caching system. Redis is an open-source, ...
user avatar
  • 75.8k
12 votes
Accepted

No Inode space!; How to delete Magento sessions folder's contents?

I wouldn't delete all sessions, start with the older ones first. Since the quote is valid for 30 days you could try going with that. In your var/session folder. find . -mtime +30 -exec rm {} \; This ...
user avatar
  • 37.4k
12 votes

Magento 2 backend session timeout

Solution for Magento 2.1+ Since Magento 2.1 the admin session lifetime is always "session", i.e. until the browser is closed. This has been might have been introduced for security reasons. The ...
user avatar
12 votes
Accepted

Web Crawler creates a lot of sessions

BOT & SESSION I'm not sure Bot needs sessions and the answer may be different for every bot for sure they don't store a cookie so it is no possible to re-use the old session matching the session ...
user avatar
  • 6,855
12 votes
Accepted

Get current order ID magento 2

below code will give you last order id protected $_checkoutSession; public function __construct( ..... \Magento\Checkout\Model\Session $checkoutSession, ..... ) { $this->...
user avatar
  • 32.1k
11 votes
Accepted

How to empty cart or clear session "externally"

This one should work as it removes all items from the current quote: Mage::getSingleton('checkout/cart')->truncate(); But you need to save it afterwards: Mage::getSingleton('checkout/cart')->...
user avatar
11 votes
Accepted

What should I choose Session Save - 'Files' or 'DB' while magento install?

This is explained pretty nice in the Magento Devdocs (actually the functionality is the same as in Magento 1): In the Session Storage Options section, click one of the following options: File to ...
user avatar
  • 17.2k
11 votes

Session validation failure in Magento 1 EE v 1.14.3.x (and CE 1.9.3.x)

6. It is programming - be creative ;) Another way to fix this (and improve session validation) ColinM @ https://github.com/OpenMage/magento-lts The session code currently stores the session ...
user avatar
  • 11.5k
11 votes

Magento2.2 - - Failed to read session data

Adding an answer for posterity as this was already correctly resolved in the comments by Anthony. When using Redis to store the session data, the Warning: session_start(): Failed to read session data ...
user avatar
  • 1,241
10 votes
Accepted

How to stay logged into Magento 2.0 longer

Go to Stores > Config > Advanced > Admin > Security and edit the Admin Session Lifetime field. This is in seconds, for development purposes I usually go for 28800 which is 8 hours.
user avatar
  • 15.3k
10 votes

Login and redirect customer to his website

First,you need to do some changes in setting. Share customer accounts between multiple Website You should configure this feature here: System -> Configuration -> Customer Configuration -> ...
user avatar
  • 75.8k
9 votes

unable to get customer data from session in custom module?

You need to check customer is loggedin or not. Without customer loggin,you cannot get customer data from session: if (Mage::getSingleton('customer/session')->isLoggedIn()): $customer = Mage::...
user avatar
  • 75.8k
9 votes
Accepted

keeping customers logged in after deleting var/session in magento

No. The sessions are what keeps your customers logged in. But deleting all the sessions can't be the solution to whatever problem you face. Either it's enough to delete cookies to loose your own ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible