Magento 2.1.x ->
Go to Stores > Settings > Configuration > General > Web > Default Cookie Settings > Cookie Lifetime
Magento 1 ->
System > Configuration > Web > Session Cookie Management
Magento 2.1.x ->
Go to Stores > Settings > Configuration > General > Web > Default Cookie Settings > Cookie Lifetime
Magento 1 ->
System > Configuration > Web > Session Cookie Management