php yii-web-Session类(方法)实例源码

下面列出了php yii-web-Session 类(方法)源码代码实例,从而了解它的用法。

作者:vovanch    项目:yii2tes   
public function actionSetwindowguid()
 {
     $guid = (string) filter_input(INPUT_POST, 'guid');
     $pathname = (string) filter_input(INPUT_POST, 'path');
     $search = (string) filter_input(INPUT_POST, 'search');
     $session = new Session();
     $session->open();
     $res = isset($session['WindowsGUIDs']) ? $session['WindowsGUIDs'] : [];
     $currentguid = $session['WindowsGUIDCurrent'];
     $gohome = false;
     $homeurls = ["", "?r=site%2Findex", "?r=site%2Flogin", "?r=site%2Flogout", "?r=site%2Ferror"];
     $ishome = in_array($search, $homeurls);
     if (empty($guid)) {
         // Если новая вкладка
         for ($i = 0; $i < 6; $i++) {
             $guid .= dechex(rand(0, 15));
         }
         $res[$guid] = 1;
         $session['WindowsGUIDs'] = $res;
         $session['WindowsGUIDCurrent'] = $guid;
         $gohome = !$ishome;
     } else {
         // Если существующая вкладка
         if ($session['WindowsGUIDCurrent'] === $guid) {
             // Если текущая вкладка
         } else {
             // Если другая существующая вкладка
             $session['WindowsGUIDCurrent'] = $guid;
             $gohome = !$ishome;
         }
         $session['WindowsGUIDs'] = $res;
     }
     $session->close();
     echo json_encode((object) ['guid' => $guid, 'gohome' => $gohome]);
 }

作者:nirantarno    项目:paperles   
/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Reqdevice::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     //        $query->andFilterWhere([
     //            'recid' => $this->recid,
     //            'jobtype' => $this->jobtype,
     //            'jobaction' => $this->jobaction,
     //            'jobdate' => $this->jobdate,
     //            'aproveddate' => $this->aproveddate,
     //            'requestby' => $this->requestby,
     //            'approvedby' => $this->approvedby,
     //            'jobstatus' => $this->jobstatus,
     //            'startdate' => $this->startdate,
     //            'enddate' => $this->enddate,
     //            'operateby' => $this->operateby,
     //        ]);
     $session = new Session();
     $session->open();
     if ($session['groupid'] != 1) {
         $query->orFilterWhere(['like', 'jobtitle', $this->globalSearch])->orFilterWhere(['like', 'comment', $this->globalSearch])->andFilterWhere(['=', 'jobtype', 4])->andFilterWhere(['=', 'requestby', $session['userid']]);
     } else {
         $query->orFilterWhere(['like', 'jobtitle', $this->globalSearch])->orFilterWhere(['like', 'comment', $this->globalSearch])->andFilterWhere(['=', 'jobtype', 4]);
     }
     return $dataProvider;
 }

作者:janwillem    项目:sa-matche   
private function redirect($tud)
 {
     $session = new Session();
     $session->open();
     $session['tud'] = $tud;
     return \Yii::$app->response->redirect(Url::to(['/authentication/response']));
 }

作者:74Genesi    项目:BooksCatalog-yii   
/**
  * Updates an existing Books model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $session = new Session();
     $session->open();
     $oldFile = $model->preview;
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $file = UploadedFile::getInstance($model, 'image');
         $model->image = $file;
         // Если изображение выбрано, загрузить его и удалить старое
         if (!empty($model->image)) {
             $filename = uniqid();
             $model->image = $file;
             $model->preview = $filename . "." . $model->image->getExtension();
             if ($model->save()) {
                 $file->saveAs($model->getUplDir() . $filename . "." . $model->image->getExtension());
                 if (file_exists($model->getUplDir() . $oldFile)) {
                     @unlink($model->getUplDir() . $oldFile);
                 }
                 return $this->redirect("?" . $session['urlParam']);
             }
         } else {
             if ($model->save()) {
                 return $this->redirect("?" . $session['urlParam']);
             }
         }
     }
     return $this->render('update', ['model' => $model]);
 }

作者:kanio    项目:yii2po   
public function actionCompany()
 {
     $company = Company::find()->one();
     if (empty($company)) {
         $company = new Company();
         $company->vat = 0;
         $company->logo = '';
     }
     $post = Yii::$app->request->post();
     if (!empty($post)) {
         if (!empty($_FILES['Company']['name']['logo'])) {
             $tmp_name = $_FILES['Company']['tmp_name']['logo'];
             $name = $_FILES['Company']['name']['logo'];
             if (file_exists('upload/' . $name)) {
                 unlink('upload' . $name);
             }
             if (move_uploaded_file($tmp_name, 'upload/' . $name)) {
                 $company->logo = $name;
             }
         }
         $company->name = $post['Company']['name'];
         $company->tax_code = $post['Company']['tax_code'];
         $company->tel = $post['Company']['tel'];
         $company->website = $post['Company']['website'];
         $company->address = $post['Company']['address'];
         $company->vat = $post['Company']['vat'];
         if ($company->save()) {
             $session = new Session();
             $session->setFlash('message', 'บันทึกรายการแล้ว');
             return $this->redirect(['company']);
         }
     }
     return $this->render('//config/company', ['company' => $company]);
 }

作者:budipratam    项目:admin_lt   
/**
  * Lists all CallHistory models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new CallHistorySearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $session = new Session();
     $session->set('dataProvider', $dataProvider);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }

作者:pichai251    项目:gov_book201   
public function actionDelete($id)
 {
     Category::findOne($id)->delete();
     $session = new Session();
     $session->open();
     $session->setFlash('message', 'Deleted.');
     return $this->redirect(['index']);
 }

作者:nirantarno    项目:paperles   
public function init()
 {
     $session = new Session();
     $session->open();
     if (empty($_SESSION['userid'])) {
         return $this->redirect('index.php?r=login/login');
     }
 }

作者:pichai251    项目:gov_book201   
public function actionLogout()
 {
     $session = new \yii\web\Session();
     $session->open();
     unset($session['account_id']);
     unset($session['account_name']);
     return $this->redirect('index.php?r=backend/index');
 }

作者:pichai251    项目:gov_book201   
public function init()
 {
     $session = new Session();
     $session->open();
     if (empty($session['account_id'])) {
         return $this->redirect('index.php?r=backend/index');
     }
     parent::init();
 }

作者:nirantarno    项目:st   
public function actionRegis()
 {
     if (\yii::$app->request->isAjax) {
         $module = \yii::$app->request->post('module');
         $session = new Session();
         $session->open();
         $session['module'] = $module;
     }
 }

作者:nirantarno    项目:S   
/**
  * Creates a new Saleorderinvoice model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $searchModel = \backend\models\Saleorderinvoiceline::find()->where(['invid' => 0]);
     $model = new Saleorderinvoice();
     if ($model->load(Yii::$app->request->post())) {
         $chkcount = Saleorderinvoice::find()->where(['invoiceno' => $_POST['Saleorderinvoice']['invoiceno']])->count();
         if ($chkcount > 0) {
             //                print_r($model->errors);
             //                echo 'Not save';
             $session = new Session();
             $session->open();
             $session->setFlash('modelerror', 'เลขที่ Invoice ซ้ำ');
             return $this->render('create', ['model' => $model, 'saleline' => $searchModel, 'rowcount' => 0, 'saleincluded' => null, 'saleincludedcount' => 0]);
         }
         $saledate = $_POST['Saleorderinvoice']['invoicedate'];
         $model->invoicedate = date('d/M/Y H:i:s', strtotime($saledate));
         // $model->createby =$session['username'];
         if ($model->save()) {
             $uploaded = UploadedFile::getInstance($model, 'upfile');
             $result = 0;
             if (!empty($uploaded)) {
                 $upfiles = time() . "." . $uploaded->getExtension();
                 $uploaded->saveAs('../../uploads/' . $upfiles);
                 $handle = fopen('../../uploads/' . $upfiles, 'r');
                 $n = 0;
                 while (($fileop = fgetcsv($handle, 1000, ",")) !== false) {
                     if ($n < 1) {
                         $n++;
                         continue;
                     }
                     $model2 = new \backend\models\Saleorderinvoiceline();
                     $model2->invid = $model->recid;
                     $model2->invline = $fileop[0];
                     $model2->partno = $fileop[1];
                     $model2->description = iconv("TIS-620", "UTF-8", $fileop[2]);
                     $model2->quantity = $fileop[3];
                     $model2->unitprice = $fileop[4];
                     $model2->totalamount = $fileop[5];
                     $model2->unit = 1;
                     if ($model2->save()) {
                         $result++;
                     }
                 }
                 fclose($handle);
                 if ($result > 0) {
                     $session = new \yii\web\Session();
                     $session->open();
                     $session->setFlash('msgsuccess', 'บันทึกรายการเรียบร้อย');
                     return $this->redirect(['update', 'id' => $model->recid]);
                 }
             }
         } else {
         }
     }
     return $this->render('create', ['model' => $model, 'saleline' => $searchModel, 'rowcount' => 0, 'saleincluded' => null, 'saleincludedcount' => 0]);
 }

作者:uraankhayayaa    项目:aic.s-vfu.r   
public function bootstrap($app)
 {
     $session = new Session();
     $session->open();
     if (isset($session['lang'])) {
         $app->language = $session['lang'];
         return;
     }
     $app->language = Yii::$app->params['defaultLang'];
 }

作者:budipratam    项目:admin_lt   
/**
  * Lists all CallSummary models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new CallSummarySearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     // echo "<pre>";
     // print_r($dataProvider);
     $session = new Session();
     $session->set('dataProviderCallSummary', $dataProvider);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }

作者:nirantarno    项目:S   
public function actionLogout()
 {
     if (isset($_SESSION['userid'])) {
         $session = new Session();
         $session->remove('userid');
         $session->remove('username');
         $session->remove('groupid');
     }
     return $this->redirect('index.php?r=login');
 }

作者:Sheriye    项目:G5-CR   
/**
  * Главный экшн для клиента это отчеты которые пришли от менеджера
  * Проверен (21.12.15)
  */
 public function actionReports()
 {
     //Сессия необходима для создания временного файла для хранения картинок до создания товара
     $session = new Session();
     $session->open();
     //cs - CREATE SESSION ID
     $session['cs_' . Yii::$app->user->identity->id] = md5(time() . rand(0, 10000));
     $projects = Project::find()->where(['for_user_id' => Yii::$app->user->identity->id])->all();
     return $this->render('reports', compact('projects'));
 }

作者:roman197    项目:li   
public function Add($id)
 {
     $session = new Session();
     $session->open();
     $cart = $session->get('cart', []);
     if (empty($cart[$id])) {
         $cart[$id] = 1;
     } else {
         $cart[$id]++;
     }
 }

作者:apaow    项目:yii2-oracle-logi   
public function run()
 {
     $session = new Session();
     if (!@oci_connect($this->username, $this->password, $this->dsn, "AL32UTF8")) {
         $e = oci_error();
         $session->set('oracle_error', $e['message']);
         return false;
     } else {
         return true;
     }
 }

作者:nirantarno    项目:paperles   
public function actionShowjob()
 {
     $session = new Session();
     $session->open();
     $model = Alljobs::find()->where(['recid' => $session['recid']])->all();
     if ($model) {
         $session->remove('recid');
         $this->layout = 'mylayout';
         return $this->render('index', ['model' => $model]);
     }
 }

作者:Sheriye    项目:G5-CR   
/**
  * Список поручений отправленные менеджером
  */
 public function actionAssignments()
 {
     //Сессия необходима для создания временного файла для хранения картинок до создания товара
     $session = new Session();
     $session->open();
     //cs - CREATE SESSION ID
     $session['cs_' . Yii::$app->user->identity->id] = md5(time() . rand(0, 10000));
     $searchModel = new AssignmentSearch();
     $dataProvider = $searchModel->searchForTeam(Yii::$app->request->queryParams);
     return $this->render('assignments', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }


问题


面经


文章

微信
公众号

扫码关注公众号