You can use class Magento\Customer\Model\Session
which will give you customer session object.
For example:
protected $customerSession;
public function _construct(
...
\Magento\Customer\Model\Session $customerSession
...
) {
...
$this->customerSession = $customerSession;
...
}
public function getName() {
return $this->customerSession->getCustomer()->getName();
}
In above example, you will get customer's name from customer session if you can getName()
function.
Now, to get a custom session value, you must set it first (if it is not already set somewhere else). Here is how you can set it.
$testValue = 'this is test';
$this->customerSession->setTestValue($testValue);
Now, you have a custom session value available in customer session. You can get this value from your module using below code:
$testValue = $this->customerSession->getTestValue();