Last active
May 20, 2019 11:55
-
-
Save magevision/07952f440c0f914e29b92e957caa67f2 to your computer and use it in GitHub Desktop.
AddACustomSession
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
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | |
<virtualType name="MageVision\Blog43\Model\Session\Storage" type="Magento\Framework\Session\Storage"> | |
<arguments> | |
<argument name="namespace" xsi:type="string">blog43</argument> | |
</arguments> | |
</virtualType> | |
<type name="MageVision\Blog43\Model\Session"> | |
<arguments> | |
<argument name="storage" xsi:type="object">MageVision\Blog43\Model\Session\Storage</argument> | |
</arguments> | |
</type> | |
</config> |
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 | |
namespace MageVision\Blog43\Model; | |
use Magento\Framework\Session\SessionManager; | |
/** | |
* Blog43 session model | |
*/ | |
class Session extends SessionManager | |
{ | |
} |
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 | |
namespace MageVision\Blog43\Block; | |
use Magento\Framework\View\Element\Template; | |
use MageVision\Blog43\Model\Session; | |
class TestBlockClass extends Template | |
{ | |
/** | |
* @var Session | |
*/ | |
protected $session; | |
/** | |
* @param Session $productOptionFactory | |
*/ | |
public function __construct( | |
Session $session | |
) { | |
$this->session = Session; | |
} | |
public function sessionData() | |
{ | |
$this->session->setData('custom', 'value'); | |
$this->session->getData('custom'); | |
$this->session->unsetData('custom'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment