I need to create a script that let customer to get status connected on Magento 2 when he connect in an external website (CakePhp) NB: Magento and CakePhp are in the same server.

when I use this script:

ini_set('display_errors', 1);
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
$storeManager = $obj->get('\Magento\Store\Model\StoreManagerInterface');
$objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
$state = $objectManager->get('Magento\Framework\App\State');
$productMetadata = $objectManager->get('Magento\Framework\App\ProductMetadataInterface');

$customerEmail ="[email protected]";

$CustomerModel = $objectManager->create('Magento\Customer\Model\Customer');
$CustomerModel->setWebsiteId(1); //Here 1 means Store ID**
$customerId = $CustomerModel->getId();

echo $customerId ;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
// Load customer
$customer = $objectManager->create('Magento\Customer\Model\Customer')->load($customerId);
// Load customer session
$customerSession = $objectManager->create('Magento\Customer\Model\Session');
if($customerSession->isLoggedIn()) {
    echo "Customer Logged in";
    echo "customer is Not Logged in";

When I execute this code I have this error in cakephp

Error: Cannot redeclare Zend\Diactoros\createUploadedFile()
File /vendor/laminas/laminas-diactoros/src/functions/create_uploaded_file.legacy.php


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.