当前位置: 首页>>代码示例>>PHP>>正文


PHP web\Session类代码示例

本文整理汇总了PHP中yii\web\Session的典型用法代码示例。如果您正苦于以下问题:PHP Session类的具体用法?PHP Session怎么用?PHP Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionSetwindowguid

 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]);
 }
开发者ID:vovancho,项目名称:yii2test,代码行数:35,代码来源:SiteController.php

示例2: search

 /**
  * 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;
 }
开发者ID:nirantarnoy,项目名称:paperless,代码行数:39,代码来源:ReqdeviceSearch.php

示例3: redirect

 private function redirect($tud)
 {
     $session = new Session();
     $session->open();
     $session['tud'] = $tud;
     return \Yii::$app->response->redirect(Url::to(['/authentication/response']));
 }
开发者ID:janwillemm,项目名称:sa-matcher,代码行数:7,代码来源:SAMLController.php

示例4: actionUpdate

 /**
  * 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]);
 }
开发者ID:74Genesis,项目名称:BooksCatalog-yii2,代码行数:35,代码来源:BooksController.php

示例5: actionCompany

 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]);
 }
开发者ID:kaniou,项目名称:yii2pos,代码行数:34,代码来源:ConfigController.php

示例6: actionIndex

 /**
  * 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]);
 }
开发者ID:budipratama,项目名称:admin_lte,代码行数:12,代码来源:CallHistoryController-master.php

示例7: actionDelete

 public function actionDelete($id)
 {
     Category::findOne($id)->delete();
     $session = new Session();
     $session->open();
     $session->setFlash('message', 'Deleted.');
     return $this->redirect(['index']);
 }
开发者ID:pichai2514,项目名称:gov_book2016,代码行数:8,代码来源:CategoryController.php

示例8: init

 public function init()
 {
     $session = new Session();
     $session->open();
     if (empty($_SESSION['userid'])) {
         return $this->redirect('index.php?r=login/login');
     }
 }
开发者ID:nirantarnoy,项目名称:paperless,代码行数:8,代码来源:OrganizeController.php

示例9: actionLogout

 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');
 }
开发者ID:pichai2514,项目名称:gov_book2016,代码行数:8,代码来源:BackendController.php

示例10: init

 public function init()
 {
     $session = new Session();
     $session->open();
     if (empty($session['account_id'])) {
         return $this->redirect('index.php?r=backend/index');
     }
     parent::init();
 }
开发者ID:pichai2514,项目名称:gov_book2016,代码行数:9,代码来源:ReportController.php

示例11: actionRegis

 public function actionRegis()
 {
     if (\yii::$app->request->isAjax) {
         $module = \yii::$app->request->post('module');
         $session = new Session();
         $session->open();
         $session['module'] = $module;
     }
 }
开发者ID:nirantarnoy,项目名称:st2,代码行数:9,代码来源:ReportconController.php

示例12: actionCreate

 /**
  * 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]);
 }
开发者ID:nirantarnoy,项目名称:ST,代码行数:61,代码来源:SaleorderinvoiceController.php

示例13: bootstrap

 public function bootstrap($app)
 {
     $session = new Session();
     $session->open();
     if (isset($session['lang'])) {
         $app->language = $session['lang'];
         return;
     }
     $app->language = Yii::$app->params['defaultLang'];
 }
开发者ID:uraankhayayaal,项目名称:aic.s-vfu.ru,代码行数:10,代码来源:langManager.php

示例14: actionIndex

 /**
  * 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]);
 }
开发者ID:budipratama,项目名称:admin_lte,代码行数:14,代码来源:CallSummaryController.php

示例15: actionLogout

 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');
 }
开发者ID:nirantarnoy,项目名称:ST,代码行数:10,代码来源:LoginController.php


注:本文中的yii\web\Session类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。