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"]);
    }
    }
?>

 

posted @ 2016-05-17 17:09  雨落知音  阅读(216)  评论(0编辑  收藏  举报