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


PHP Session::set方法代码示例

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


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

示例1: actionStart

 public function actionStart()
 {
     if ($this->game->isFinished()) {
         return $this->redirect('/game/finished');
     }
     if ($this->game->isStarted()) {
         return $this->redirect('/game/overview');
     }
     $this->game->start();
     if ($this->game->isStarted()) {
         $this->session->set('started', true);
         $this->storage->save($this->game);
         return $this->redirect('/game/overview');
     }
 }
开发者ID:macseem,项目名称:bee-game,代码行数:15,代码来源:GameController.php

示例2: ip

 /**
  * @param string|null $ip
  * @return Result
  */
 public function ip($ip = null)
 {
     if ($ip === null) {
         $ip = Yii::$app->request->getUserIP();
     }
     if (!array_key_exists($ip, $this->result)) {
         $key = self::className() . ':' . $ip;
         if ($this->session->offsetExists($key)) {
             $this->result[$ip] = $this->session->get($key);
         } else {
             $result = $this->reader->get($ip);
             $this->result[$ip] = new Result($result);
             $this->session->set($key, $this->result[$ip]);
         }
     }
     return $this->result[$ip];
 }
开发者ID:andrewblake1,项目名称:yii2-geoip,代码行数:21,代码来源:GeoIP.php

示例3: 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

示例4: 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

示例5: run

 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;
     }
 }
开发者ID:apaoww,项目名称:yii2-oracle-login,代码行数:11,代码来源:OracleLogin.php

示例6: runAction

 /**
  * @param string $id
  * @param array $params
  * @return mixed|\yii\web\Response
  * @throws \yii\base\InvalidRouteException
  */
 public function runAction($id, $params = [])
 {
     // See if it's ok to view this controller->action anonymously
     $resolvedActionName = $id ? $id : $this->defaultAction;
     if (!$this->member && !in_array($resolvedActionName, $this->anonActions)) {
         // nope
         $this->session->set('redirectAfterLogin', $_SERVER['REQUEST_URI']);
         return $this->redirect('/login');
     } else {
         return parent::runAction($id, $params);
     }
 }
开发者ID:jc21,项目名称:snippets-site,代码行数:18,代码来源:Controller.php

示例7: actionIndex

 /**
  * Lists all CallHistory models.
  * @return mixed
  */
 public function actionIndex()
 {
     // $searchModel = new CallHistorySearch();
     // $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $searchModel = new CallHistory();
     $connection = Yii::$app->db;
     if (isset($_GET['CallHistory'])) {
         $monthStart = substr($_GET['CallHistory']['start_time'], 5, 2);
         $monthEnd = substr($_GET['CallHistory']['end_time'], 5, 2);
         $yearStart = substr($_GET['CallHistory']['start_time'], 0, 4);
         $yearEnd = substr($_GET['CallHistory']['end_time'], 0, 4);
         $startTime = $_GET['CallHistory']['start_time'];
         $endTime = $_GET['CallHistory']['end_time'];
         $Anumber = $_GET['CallHistory']['Anumber'];
         $Bnumber = $_GET['CallHistory']['Bnumber'];
         $Zon = $_GET['CallHistory']['Zon'];
         $Trunk1 = $_GET['CallHistory']['Trunk1'];
         $Trunk2 = $_GET['CallHistory']['Trunk2'];
         $query = "SELECT * FROM (SELECT * FROM tbl_call_history_{$yearStart}{$monthStart} UNION SELECT * FROM tbl_call_history_{$yearEnd}{$monthEnd}) AS maho WHERE start_time BETWEEN '{$_GET['CallHistory']['start_time']}' AND '{$_GET['CallHistory']['end_time']}'";
         $params = [];
         if (!empty($Anumber)) {
             $query .= " AND Anumber LIKE :Anumber";
             $params = [':Anumber' => "%{$Anumber}%"];
         }
         if (!empty($Bnumber)) {
             $query .= " AND Bnumber LIKE :Bnumber";
             $params = [':Anumber' => "%{$Anumber}%"];
         }
         if (!empty($zon)) {
             $query .= " AND Zon LIKE {$zon}";
             $params = [':Zon' => "%{$Zon}%"];
         }
         if (!empty($Trunk1)) {
             $query .= " AND Trunk1 LIKE :Trunk1";
             $params = [':Trunk1' => "%{$Trunk1}%"];
         }
         if (!empty($Trunk2)) {
             $query .= " AND Trunk2 LIKE :Trunk2'";
             $params = [':Trunk2' => "%{$Trunk2}%"];
         }
         $data = $connection->createCommand($query)->bindValues($params)->queryAll();
     } else {
         $query = "SELECT * FROM (SELECT * FROM tbl_call_history_201509 UNION SELECT * FROM tbl_call_history_201509) AS maho ";
         $data = $connection->createCommand($query)->queryAll();
     }
     $provider = new ArrayDataProvider(['allModels' => $data, 'sort' => ['attributes' => ['start_time', 'ed_time', 'Anumber', 'Bnumber', 'Zon', 'Trunk1', 'Trunk2']], 'pagination' => ['pageSize' => empty($_GET['per-page']) ? 10 : $_GET['per-page']]]);
     $session = new Session();
     $session->set('dataProviderCallHistory', $provider);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $provider]);
 }
开发者ID:budipratama,项目名称:admin_lte,代码行数:54,代码来源:CallHistoryController.php

示例8: findByUsername

 /**
  * Знайти користувача
  * @param  string $username Логін користувача
  * @return static|null
  */
 public static function findByUsername($username)
 {
     $instagram = new Instagram($username);
     if ($instagram->hasUser()) {
         $model = new static();
         $model->id = $instagram->getId();
         $model->instagram = $instagram;
         $model->username = $instagram->getLogin();
         $session = new Session();
         $session->set($model->id . '_' . __CLASS__, serialize($model));
         return $model;
     }
     return null;
 }
开发者ID:serj1chen,项目名称:college_uawebchallenge,代码行数:19,代码来源:User.php

示例9: actionLogin

 public function actionLogin()
 {
     $modelLoginFrom = new LoginForm();
     if ($modelLoginFrom->load(\Yii::$app->getRequest()->getBodyParams(), '') && $modelLoginFrom->login()) {
         $post = \Yii::$app->getRequest()->getBodyParams();
         $modelUser = new User();
         $modelRole = new Role();
         $result = $modelRole->find()->where(['=', 'role_id', \Yii::$app->user->identity->getRole()])->all();
         $resultuserdata = $modelUser->find()->where(['=', 'username', $post['username']])->one();
         $session = new Session();
         $session->open();
         $session->set('role', $result[0]->name);
         $session->close();
         return ['username' => $post['username'], 'role' => $result[0]->name, 'isLogined' => true, 'userDataID' => $resultuserdata->user_data_id];
     } else {
         return $modelLoginFrom;
     }
 }
开发者ID:romangrb,项目名称:resource-registry,代码行数:18,代码来源:UserController.php

示例10: actionLogin

 public function actionLogin()
 {
     // error_reporting(0);
     $model = new LoginForm();
     $model->scenario = 'login';
     if ($model->load(Yii::$app->request->post()) && $model->login()) {
         // check change password date
         if (Yii::$app->user->ChangePassDate == "") {
             $session = new Session();
             $session->set('user_id', $model->username);
             return $this->redirect(array('site/change-password'));
         }
         self::updateLastAction();
         return $this->goBack();
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }
开发者ID:budipratama,项目名称:admin_lte,代码行数:18,代码来源:SiteController.php

示例11: actionCheckout

 public function actionCheckout()
 {
     $case = new Apcase();
     $request = \Yii::$app->request;
     if (empty($request->post()) && empty($request->post('app_date'))) {
         return $this->redirect(['index']);
     }
     if (empty($request->post('menstrual_date'))) {
         $ms_period = "n/a";
     } else {
         $ms_period = $request->post('menstrual_date');
     }
     //file upload start
     $uploaded_files = [];
     $case->imageFiles = UploadedFile::getInstances($case, 'imageFiles');
     $upload_result = $case->upload();
     if (is_array($case->imageFiles) && count($case->imageFiles) > 0) {
         foreach ($case->imageFiles as $file) {
             array_push($uploaded_files, $file->name);
         }
     }
     //file upload ends
     $date = date("Y-m-d H:i:s");
     $case->user_id = \Yii::$app->user->id;
     $case->what_brought_you = $request->post('in_cause');
     $case->location_of_symptom = $request->post('symptoms_location');
     $case->quality_of_symptoms = $request->post('symptoms');
     $case->severity_of_symptoms_right_now = $request->post('severity');
     $case->severity_of_symptoms_during_episode = $request->post('severity_duration');
     $case->symptoms_been_going_on_for = $request->post('symptoms_has_been');
     $case->symptoms_type = $request->post('consis');
     $case->symptoms_last_for = $request->post('eps_symptoms_last_for');
     $case->when_symptom_occur = $request->post('when_got_sysmptoms');
     $case->factors_that_make_symptoms_better = $request->post('better_symptoms');
     $case->factors_that_make_symptoms_worse = $request->post('worse_symptoms');
     $case->associated_symptoms = $request->post('associated_symptoms');
     $case->other_associated_symptoms = $request->post('other_assoc_symp');
     $case->medical_problems_treated_for = serialize($request->post('problem_treated'));
     $case->other_medical_problems_treated_for = $request->post('other_prob_treated');
     $case->past_surgeries = serialize($request->post('past_surgeries'));
     $case->other_past_surgeries = $request->post('other_past_surgeries');
     $case->medications_taken = $request->post('medication_taken');
     $case->allergies = $request->post('allergies');
     $case->ast_menstrual_period = $ms_period;
     $case->primary_doctor = $request->post('doctor_first_name') . ' ' . $request->post('doctor_last_name');
     $case->where_can_they_be_reached = $request->post('can_reached');
     $case->martial_status = $request->post('martial_status');
     $case->occupation = $request->post('occupation');
     $case->habits = $request->post('habits');
     $case->family_history = $request->post('family_history');
     $case->other_family_history = $request->post('other_family_history');
     $case->firtst_name = $request->post('first_name');
     $case->last_name = $request->post('last_name');
     $case->files = serialize($uploaded_files);
     $case->save();
     $appointment_id = $case->id;
     $session = \Yii::$app->session;
     $session = new Session();
     $session->open();
     $session->set('apid', $appointment_id);
     if (\Yii::$app->user->isGuest) {
         return $this->render("index_guest", array());
     } else {
         return $this->render("checkout", array("showProfilePostForm" => Setting::Get("showProfilePostForm", "appointments")));
     }
 }
开发者ID:vinodchandel,项目名称:modules,代码行数:66,代码来源:CasesController.php

示例12: actionCheckout

 public function actionCheckout()
 {
     $session = new Session();
     $session->open();
     $cart = $session->get('cart');
     $billOrder = new BillOrder();
     if (!empty($_POST)) {
         // save bill order
         $billOrder->member_id = $session->get('member_id');
         $billOrder->ip = $_SERVER['REMOTE_ADDR'];
         $billOrder->created_at = new Expression('NOW()');
         $billOrder->status = 'wait';
         $billOrder->name = $_POST['BillOrder']['name'];
         $billOrder->address = $_POST['BillOrder']['address'];
         $billOrder->tel = $_POST['BillOrder']['tel'];
         if ($billOrder->save()) {
             // loop read data from session to database
             foreach ($cart as $c) {
                 $billOrderDetail = new BillOrderDetail();
                 $billOrderDetail->bill_order_id = $billOrder->id;
                 $billOrderDetail->product_id = $c['id'];
                 $billOrderDetail->price = $c['price'];
                 $billOrderDetail->qty = $c['qty'];
                 $billOrderDetail->save();
             }
             // clear session
             $session->set('cart', null);
             return $this->redirect(['checkoutsuccess']);
         }
     }
     return $this->render('//Frontend/Checkout', ['n' => 1, 'cart' => $cart, 'sumQty' => 0, 'sumPrice' => 0, 'billOrder' => $billOrder]);
 }
开发者ID:pichai2514,项目名称:gov_book2016,代码行数:32,代码来源:FrontendController.php

示例13: save

 /**
  * @param GameInterface $game
  */
 public function save(GameInterface $game)
 {
     $this->session->set('game', serialize($game));
 }
开发者ID:macseem,项目名称:bee-game,代码行数:7,代码来源:SessionStorage.php

示例14: save

 /**
  * Saves data into the Session.
  * This is normally called automatically after the Event::WIZARD_PROCESS_STEP event,
  * but can be called directly for advanced navigation purposes.
  *
  * @param mixed $data Data to be saved
  * @param string $step Step name. If empty the current step is used.
  */
 public function save($data, $step = null)
 {
     $stepsData = $this->_session->get($this->_stepsKey, []);
     $stepsData[empty($step) ? $this->_currentStep : $step] = $data;
     $this->_session->set($this->_stepsKey, $stepsData);
 }
开发者ID:yii-dream-team,项目名称:yii2-wizard-behavior,代码行数:14,代码来源:Behavior.php


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