magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Session Does not work

Open carmelomtb opened this issue 10 years ago • 2 comments

Customer and Default Session (I'have not test the other types) doen not work. Also the php variable $_SESSION contains bad values. This issue is reproducible in magento 2.1.0-rc1, 2.0.7, 2.0.6, and lower versions. You can reproduce the bug in the following way:

  1. Install a magento 2.1.0-rc1 or a lower version

  2. Change deploy mode to developer: php bin/magento deploy:mode:set developer

  3. Download and install this module: Test.zip

  4. Make sure all cache types are enabled

  5. Go to home page, under the LUMA logo you can see "Session status: " The ReadSession.php Block will execute the following code: $session=$this->_session; $session->start(); return $session->getMessage(); The template read-session.phtml will execute: `Session status:

readSession();` 6) Go to page "setsession/save", if your magento installation folder is magento21 follow this link http://localhost/magento21/setsession/save The module will execute the following code: `$session=$this->_objectManager->get('\Magento\Framework\Session\SessionManagerInterface'); $session->start(); $session->setMessage('The session works');` You can see under the LUMA Logo: **"Session status: The session works"** 7) Go to home page, under the LUMA logo you can see (**the bug** ): **"Session status: "** When the session works you can see: **"Session status: The session works"** 8) In home page go to search box, digit something and press enter, you can see: **"Session status: The session works"** In this case form some unknown reason the session works 9) Disable **Full Page Cache** 10) Clear all cache type 11) Go to page "setsession/save" 12) Go to home page, now the session works so you can see: **"Session status: The session works"**

carmelomtb avatar Jun 06 '16 16:06 carmelomtb

@carmelomtb, looking at your description it would appear that your home page is cached under full page cache on the first call, prior to the session message being set. After setting the session message and returning to the home page you are receiving the cached version of the home page, which did not cache the session message.

You should take care in including session specific content in the rendered page, as you could inadvertently display customer data to other users. You may want to look at delivering customer specific data via ajax and using knockout.js to display the necessary data. This will allow you to continue to utilize the full page cache.

toddwolaver avatar Jun 06 '16 17:06 toddwolaver

Hi @carmelomtb , GitHub issue tracker is intended for technical issues only, not questions and technical assistance. Please refer to the Community Forums or Magento Stack Exchange site for technical questions. In your case, the programming questions forum is likely the most appropriate. https://community.magento.com/t5/Programming-Questions/bd-p/programming-magento-2

mslabko avatar Jun 09 '16 11:06 mslabko