Session is set on the server not client. If you want some control on client then use cookies not session. But then you cannot store sensitive information since user can inspect cookie and that user might happen to be malicious!
The time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch. One way to set this is by adding the number of seconds before the cookie should expire to the result of calling time(). For instance, time()+60*60*24*30 will set the cookie to expire in 30 days. Another option is to use the mktime() function. If set to 0, or omitted, the cookie will expire at the end of the session (when the browser closes).
For Yii2
// get the cookie collection (yii\web\CookieCollection) from the "response" component
$cookies = Yii::$app->response->cookies;
// add a new cookie to the response to be sent
$cookies->add(new \yii\web\Cookie([
'name' => 'language',
'value' => 'zh-CN',
'expire' => 0
]));