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 ...
Arkadii Chyzhov's user avatar
57 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 ...
Fabian Schmengler's user avatar
42 votes

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 ...
Mubashar Aftab's user avatar
38 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 ...
Fabian Schmengler's user avatar
32 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( ... ...
Frank's user avatar
  • 1,144
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 ...
Anton Boritskiy's 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". ...
Siarhey Uchukhlebau's user avatar
24 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 ...
Amit Bera's user avatar
  • 77.5k
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 ...
Sergii Ivashchenko's 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.
Yogesh Trivedi's user avatar
20 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->...
Rahul Katoch's user avatar
  • 1,119
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/...
SR_Magento's user avatar
  • 5,209
19 votes

Can we increase the system/security/session size at admin On Magento 2

Magento 2.4.3 introduces a setting for max session size with default value 256000. To increase the max session size for admin and prevent Session size of 123456 exceeded allowed session max size of ...
Gerard de Visser's user avatar
17 votes

Unable to login to admin (no error message) stuck at login screen

Well, there could be a number of reasons and it's not just like a cookie issue cause it really depends on the version you're running on. Here are the steps Make sure that you will take a backup of the ...
samumaretiya's user avatar
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.
Jaimin Parikh's user avatar
14 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 ...
Fabian Schmengler's 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 ...
Fra's user avatar
  • 6,965
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->...
Qaisar Satti's user avatar
  • 32.5k
12 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 ...
Marina Gociu's user avatar
  • 1,261
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 ...
sv3n's user avatar
  • 11.7k
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.
Ben Crook's user avatar
  • 15.7k
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 -> ...
Amit Bera's user avatar
  • 77.5k
10 votes
Accepted

Cannot get customer session in Controller

I think you need do it : PS: "purpose of all these dependency injections" use Factory ." Example : ... protected $sessionFactory; ... public function __construct( ... \Magento\...
Eugene Kapelko's user avatar
9 votes

Magento 2.2.2: Customer session not working with cache enable

The best practice is to use Magento\Framework\App\Http\Context to check the customer logged in or not. And, avoiding using Object Manager directly. For example: <?php namespace Vendor\Customer\...
Khoa TruongDinh's user avatar
9 votes
Accepted

How Can I change Session save path?

You can change session save path from file /app/etc/env.php 'session' => array ( 'save' => 'files', 'save_path' => '/var/www/session', ), Read magento Doc for more info: http://...
akgola's user avatar
  • 2,927
9 votes
Accepted

Magento 2 Admin Page Error: Your current session has been expired

Find path admin/security/session_lifetime in core_config_data table If it's present then set its value to 86400 If that path is not present then add it with value 86400 INSERT INTO `...
Mukesh Chapagain's user avatar
9 votes
Accepted

Redis Session Error: Successfully broke lock for ID sess_ebfc12b22fa8c8e1fb81dca122fcdda6 after 5.01422 seconds

Finally able to resolve this issue by changing below configurations for Redis: break_after_frontend changed from 5 to 30 max_concurrency => changed from 6 to 25 break_after_frontend was the main ...
Ahsan Horani's user avatar
8 votes

Magento 2 backend session timeout

A note here, the accepted answer works however magento 2 uses the default php folder to store session files, if you have this configured in php: 09,39 * * * * root [ -x /usr/lib/php/...
OZZIE's user avatar
  • 552
8 votes
Accepted

Magento 2 - How to get admin user role?

You need to use DI in your class - 1. add property of AdminSession class to class 2. add including of the variable using dependensy injection: /** * @var \Magento\Backend\Model\Auth\Session */ ...
Kate  Suykovskaya's user avatar
8 votes

Magento 2: how to call checkout session in controller?

You can just try using below method, <?php namespace Demo\Demo\Controller\Demo; class Demo extends \Magento\Framework\App\Action\Action { protected $_checkoutSession; public function ...
Rakesh Jesadiya's user avatar

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