YII学习总结3(session)
session操作
<?php namespace app\controllers; use yii\web\Controller; class HelloController extends Controller{
public function actionIndex(){ //把session当做对象 $session = \yii:$app->session; if($session->isActive){ echo "session isactive"; }else{ $session->open(); } $session->set("user","张三"); $session->get("user"); $session->remove("user"); //把session当做数组 $session['user'] = "张三"; unset($session["user"]);
}
}
?>