:::: MENU ::::
Posts tagged with: session

Magento 2 change admin session duration

Today we discuss about Magento 2 change admin session duration.Sometime you need to increase the timing of session of your admin. Mostly developer while coding and testing need the admin session to stay there as they switch between browsers pages and editor . Increasing the life of session helps them to avoid logging in to admin again and again.

Login to admin panel and go to

Stores->Settings->Configuration->Advanced->Admin->Security->Admin Session Lifetime (seconds)

And check screenshot following.
Admin session duration

Author: Qaisar Satti
Category: Magento 2
Last Modified: July 31, 2018


Magento 2 get set unset session

Today we talk about how in Magento 2 get, set, and unset session. This tutorial include set session, get session and unset the session. Sometimes in customization and module development we need to get the session information , that how long a user remains on our site or we may need to unset the session given the certain amount of time . Following piece of code will let us to play with the global session variable to achieve our intended goals.

protected $coreSession;

public function __construct(
   
    \Magento\Framework\Session\SessionManagerInterface $coreSession
    ){

    $this->coreSession = $coreSession;
   
}

public function setSession(){
    $this->coreSession->start();
    $this->coreSession->setTest('The Core session');
}

public function getSession(){
    $this->coreSession->start();
    return $this->coreSession->getTest();
}

public function unSetSessione(){
    $this->coreSession->start();
    return $this->coreSession->unsTest();
}
Author: Qaisar Satti
Category: Magento 2
Last Modified: July 12, 2018