Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After enable full page cache customer session data not found. #5594

Closed
hitumca opened this issue Jul 12, 2016 · 12 comments
Closed

After enable full page cache customer session data not found. #5594

hitumca opened this issue Jul 12, 2016 · 12 comments
Labels
bug report Component: Customer Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update

Comments

@hitumca
Copy link

hitumca commented Jul 12, 2016

Steps to reproduce

  1. Magento 210
  2. Magento Backend System-> Cache Management -> enable all cache type enable.

Expected result

  1. if($customerSession->isLoggedIn()) {
    echo "logged in Customer";
    }else
    {
    echo "Not Logged In Customer";
    }
    After enable cache every time if condition not true .
  2. ...

Actual result

  1. It should be return true in customer logged in case.
@sevos1984
Copy link
Contributor

Please, format this issue according to the Issue reporting guidelines.

@andimov
Copy link
Contributor

andimov commented Sep 14, 2016

The contributor guide suggests that tickets that have not been active for two weeks should be closed. Please reopen as needed.

@andimov andimov closed this as completed Sep 14, 2016
@timbaker1991
Copy link

timbaker1991 commented Oct 8, 2016

To add to this I am able to replicate:
Preconditions:
Magento Version CE 2.1.1
PHP version 7.0.7
Full Page Caching Enabled
Chrome Version 53.0.2785.143 m

Steps to reproduce with Actual and Expected Result
When Full Page Caching is enabled this always results $customerId as null, disabling full page caching means the customerId is correctly returned.

$customerId = $this->_customerSession->getId();
            /**
             * Check the user is logged in
             */
            if (!$customerId) {
                return "User not logged in";
            }

This appears to only happen in Google Chrome. Firefox works as expected.

@Mohammed8960
Copy link

me also face same issue. is there any result ?

@anthonyherve
Copy link

I have also this issue. I try to add some custome values in CustomSession, but when I do a getCustomValue, I have nothing.
If I disable Fulle page, it's OK.
Have you an explanation please ?

Thank you.

@daniel-kratohvil
Copy link

Same here.

Setting a session using \Magento\Framework\Session\Generic on a custom Controller returns NULL on the Block when cache is enabled. With cache disabled it works fine.

@LucScu
Copy link

LucScu commented Sep 13, 2017

IT'S NOT A ISSUE! SEE HERE #3294 (comment)

@magento-engcom-team magento-engcom-team added the Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed label Sep 13, 2017
@ritwikdatta
Copy link

I am having the same problem in Magento 2.2.1 as well .. I tried following code in a .phtml file...

$om = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $om->get('Magento\Customer\Model\Session');
echo $customerSession->isLoggedIn();

it did not return anything when Page Cache is ON, and when OFF I can see a value (1) printed.

@cpjeanpaul
Copy link

What about this: https://magento.stackexchange.com/a/167112/62952

@neutronixx
Copy link

If you have a custom template just put: cacheable="false" in ypur block declaration in layout: example:

<block class="Custom\Theme\Block\Customheader" name="custom_header" as="custom_header" template="Magento_Theme::html/customheader.phtml" before="-" cacheable="false" />

@kazimnoorani8704
Copy link

You can try by creating an object of objectManager and should not use objectManager directly.

Use something like,

class Example extends \Magento\Framework\View\Element\Template
{
    private $_objectManager;
    public function __construct(
        \Magento\Framework\ObjectManagerInterface $objectmanager
    ){
        $this->_objectManager = $objectmanager;
    }

    public function getExample()
    {
        $customerSession = $this->_objectManager->create("Magento\Customer\Model\Session");
        if ($customerSession->isLoggedIn()) {
            $customerData = $customerSession->getCustomer()->getData();
            /*Your logic*/
        }
    }
}

@aartipatel6495
Copy link

I have already added cacheable="false" but it is not working in my custom block.
I have to clear cache then it is working.

magento-engcom-team pushed a commit that referenced this issue Apr 22, 2020
MQE-2081: Functional Tests builds will only pass when MFTF and MTF are selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Customer Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update
Projects
None yet
Development

No branches or pull requests