Last active
June 11, 2019 15:29
-
-
Save Alexander-Pop/ea09cbf24a8b2792a47b3555f4085ecc to your computer and use it in GitHub Desktop.
Magento - set/get Session Variable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* create new session variable foo_data | |
* You have two options, for the session name, "frontend" for frontend session or "adminhtml" for admin session | |
*/ | |
Mage::getSingleton("core/session", array("name" => "frontend")); | |
// This will get the session of the current logged in user. | |
$session = Mage::getSingleton('customer/session'); | |
$session->setFooData($login['passcode']); //$login['passcode'] is example | |
$session = Mage::getSingleton('customer/session'); | |
if($session) { | |
$myData = $session->getFooData(); | |
} | |
//And this will login to Magento from outside: | |
$session = Mage::getSingleton('customer/session', array('name' => 'frontend')); | |
$session->login($row['mail'], $row['field_magentopass_value']); | |
$session->setCustomerAsLoggedIn($session->getCustomer()); | |
//$row['mail'] is the email with user is registered $row['field_magentopass_value'] is the password | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment