简体   繁体   中英

Yii2: how can I make sure session is always started?

How can make sure session is always started in Yii2? In Yii 1.0 there seemed to be a configuratio parameter autoStart but I don't see that in Yii2.

Do I need to manually call Yii::$app->session->open() (or session_start() ), and if so, where is a good place to do that for all requests?

At the time of writing The Definitive Guide doesn't talk about it.

Every time you call method processing session data in Yii 2, session is started automatically if it hasn't started already.

You can always call Yii::$app->session->open() directly if you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM