Question: In Magento 1 my code is 

```
$customer = Mage::getSingleton('customer/session')->getCustomer();

```

How I set this code in Magento 2

Answer: 
```
Magento\Customer\Model\Session

```

is used in magento 2 to get object of Customer Session.

You can define in **\_\_construct()** of php file,

```
public function __construct(
        \Magento\Customer\Model\Session $customerSession
    ) {
        $this->_customerSession = $customerSession;
    }

```

Now you can get the info using:

```
$customer = $this->_customerSession->getCustomer();

```
```
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();

$currentCustomer = $objectManager->get('Magento\Customer\Model\Session')->getCustomer();

```

---

***Note: I am against of direct loading object with $objectManager, for better impact you can inject it in your constructor. I have just given example how you can achieve it. `***

**Better way**

---

```
protected $_customerSession;

public function __construct(
\Magento\Customer\Model\Session $_customerSession 
) {
    $this->_customerSession=$_customerSession
}

```

Now you can easily get customer by simply

```
$this->_customerSession->getCustomer();

```