session操作
<?php namespace app\controllers; use yii\web\Controller; class HelloController extends Controller{ //把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("user"); } ?>
时间: 2024-11-05 16:35:51