本文整理汇总了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]);
}
示例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;
}
示例3: redirect
private function redirect($tud)
{
$session = new Session();
$session->open();
$session['tud'] = $tud;
return \Yii::$app->response->redirect(Url::to(['/authentication/response']));
}
示例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]);
}
示例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]);
}
示例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]);
}
示例7: actionDelete
public function actionDelete($id)
{
Category::findOne($id)->delete();
$session = new Session();
$session->open();
$session->setFlash('message', 'Deleted.');
return $this->redirect(['index']);
}
示例8: init
public function init()
{
$session = new Session();
$session->open();
if (empty($_SESSION['userid'])) {
return $this->redirect('index.php?r=login/login');
}
}
示例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');
}
示例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();
}
示例11: actionRegis
public function actionRegis()
{
if (\yii::$app->request->isAjax) {
$module = \yii::$app->request->post('module');
$session = new Session();
$session->open();
$session['module'] = $module;
}
}
示例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]);
}
示例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'];
}
示例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]);
}
示例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');
}