當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Session::set方法代碼示例

本文整理匯總了PHP中Illuminate\Support\Facades\Session::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP Session::set方法的具體用法?PHP Session::set怎麽用?PHP Session::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Support\Facades\Session的用法示例。


在下文中一共展示了Session::set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: changeLocale

 public function changeLocale($locale)
 {
     if (array_key_exists($locale, Config::get('app.locales'))) {
         Session::set('applocale', $locale);
     }
     return back();
 }
開發者ID:fabricedeplancke,項目名稱:laravel,代碼行數:7,代碼來源:LanguagesController.php

示例2: check

 /**
  * 後台驗證登陸操作
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function check()
 {
     $username = Input::get('username', null);
     $password = Input::get('password', null);
     if ($username and $password) {
         $user = AdminUser::where('username', '=', $username)->first();
         if (count($user)) {
             if (sha1($password) == $user->password and $user->enable) {
                 Session::set('admin_user', $user->username);
                 Session::set('admin_id', $user->id);
                 Session::set('admin_level', $user->level);
                 if ($user->level == 1) {
                     return redirect('admin/orders/show');
                 } else {
                     return redirect('admin/promote/user/center');
                 }
             } else {
                 flash('密碼錯誤或用戶已禁用~');
                 return redirect()->back();
             }
         } else {
             flash('用戶不存在~');
             return redirect()->back();
         }
     } else {
         flash('用戶名或密碼不能為空~');
         return redirect()->back();
     }
 }
開發者ID:pinse98,項目名稱:mitao,代碼行數:34,代碼來源:AdminAuthController.php

示例3: switchLang

 public function switchLang($lang)
 {
     if (array_key_exists($lang, Config::get('languages'))) {
         Session::set('applocale', $lang);
     }
     return Redirect::back();
 }
開發者ID:Ristop,項目名稱:valgeranna,代碼行數:7,代碼來源:LanguageController.php

示例4: login

 public function login()
 {
     Session::set('admin_lock_url', null);
     $loginForm = new KForm();
     $loginForm->addField(FormFieldBase::createByType('login', FormFieldBase::Type_Text)->setRules('required')->setLabel('請輸入工號'));
     $loginForm->addField(FormFieldBase::createByType('password', FormFieldBase::Type_Password)->setRules('required')->setLabel('請輸入密碼'));
     if (AuthModel::user() !== null) {
         return Redirect::action('admin.index');
     }
     if (Request::isMethod('POST')) {
         //是管理員登陸請求
         if ($loginForm->validation()) {
             $login = $loginForm->value('login');
             $password = $loginForm->value('password');
             if (AuthModel::attempt(['employee_id' => $login, 'password' => $password])) {
                 $admin = AuthModel::getUser();
                 $admin->last_login = new \Carbon\Carbon();
                 $admin->save();
                 return Redirect::action('admin.index');
             } else {
                 $loginForm->set_error('password', '錯誤的用戶名或密碼');
             }
         } else {
             //
         }
     }
     $this->layout = View::make('laravel-cms::admin-lte/login')->with('form', $loginForm);
 }
開發者ID:xjtuwangke,項目名稱:laravel-cms,代碼行數:28,代碼來源:AdminController.php

示例5: update

 /**
  * @param Request $request
  * @return array
  */
 public function update($id, $newQtd)
 {
     $cart = $this->getCart();
     $cart->update($id, $newQtd);
     Session::set('cart', $cart);
     return redirect()->route('cart');
 }
開發者ID:andreluiz1013,項目名稱:laravel-commerce2,代碼行數:11,代碼來源:CartController.php

示例6: question

 public function question()
 {
     $user = \Auth::user();
     $isAjax = \Request::ajax();
     $correct_answers = $user->correct_answers;
     if (!$isAjax && $correct_answers >= 3) {
         Redirect::to('user/start');
     }
     $data = Question::select('title')->get();
     $value = Session::get('index');
     if ($value >= count($data) || !$value) {
         $value = 1;
     }
     if ($isAjax) {
         Session::set('index', $value + 1);
         $value = Session::get('index');
     }
     $question = \App\Question::with(array('answers' => function ($query) {
         $query->select("id", "title", "question_id");
     }))->select('id', 'title')->findOrFail($value);
     $question['correct_answers'] = $correct_answers;
     if ($isAjax) {
         return json_encode($question);
     }
     return view('auth.question', compact('question'));
 }
開發者ID:EmilAleksandrov,項目名稱:Cinegrand-laravel-5.1-ajax,代碼行數:26,代碼來源:QuestionController.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $card = Request::all();
     $user = Auth::user();
     $user_type = $user->user_type;
     if ($user_type == 'COMPANY') {
         // o bar está abrindo a comanda
         $id_company = $user->id_company;
         $phone = $card['phone'];
         // pega o celular do usuario
         $user = User::where('phone', '=', $phone)->get();
         // encontra o usuario vinculado a esse celular
         foreach ($user as $row) {
             $id_user = $row->id_user;
         }
     } else {
         // o usuário está abrindo a propria comanda
         $id_user = $user->id_user;
         $phone = $user->phone;
         $id_company = $card['id_company'];
         Session::set('id_company', $id_company);
     }
     // Gera o HASH da comanda
     $full_hash = md5($id_user . $phone . $id_company . microtime() . rand());
     $hash_len = strlen($full_hash);
     // HASH FINAL
     $hash_card = strtoupper(substr($full_hash, $hash_len - 6, 6));
     $new_card = ['id_user' => $id_user, 'id_company' => $id_company, 'table' => $card['table'], 'hash_card' => $hash_card];
     Card::create($new_card);
     return redirect('comandas?card=' . $hash_card);
 }
開發者ID:sandrovw64,項目名稱:comanda-teste,代碼行數:37,代碼來源:CardController.php

示例8: update

 public function update($id, $refresh)
 {
     $cart = $this->getCart();
     $cart->novaQtd($id, $refresh);
     Session::set('cart', $cart);
     return redirect()->route('cart');
 }
開發者ID:rlopesbtu,項目名稱:Laravel_v5_commerce_v2,代碼行數:7,代碼來源:CartController.php

示例9: githubLogin

 public function githubLogin()
 {
     $access_token = Input::get('access_token');
     $ch = curl_init('https://api.github.com/user');
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: token {$access_token}"));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
     curl_setopt($ch, CURLOPT_USERAGENT, 'SWAMP');
     $response = curl_exec($ch);
     $user = json_decode($response);
     $account = LinkedAccount::where('user_external_id', '=', $user->id)->first();
     if ($account) {
         Session::set('github_access_token', $access_token);
         $user = User::getIndex($account->user_uid);
         if ($user) {
             if ($user->isEnabled()) {
                 $res = Response::json(array('user_uid' => $user->user_uid));
                 Session::set('timestamp', time());
                 Session::set('user_uid', $user->user_uid);
                 return $res;
             } else {
                 return Response::make('User has not been approved.', 401);
             }
         } else {
             return Response::make('Incorrect username or password.', 401);
         }
     } else {
         return Response::make('Account not found.', 401);
     }
 }
開發者ID:pombredanne,項目名稱:open-swamp,代碼行數:30,代碼來源:SessionController.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string  $l
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //Session::flush();
     if (!Session::has('locale')) {
         /**
          * Get the browser local code and lang code.
          */
         $localCode = $request->getPreferredLanguage();
         $localLang = substr($localCode, 0, 2);
         if (in_array($localLang, $this->lang)) {
             Session::set('locale', $localLang);
         } else {
             Session::set('locale', Config::get('app.locale'));
         }
     }
     /**
      * Set the local config.
      */
     App::setLocale(Session::get('locale'));
     Config::set('app.locale', Session::get('locale'));
     /**
      * Share variables in view.
      */
     if (Config::get('app.locale') == 'fr') {
         View::share(['lang' => 'fr', 'langreverse' => 'en']);
     } else {
         View::share(['lang' => 'en', 'langreverse' => 'fr']);
     }
     return $next($request);
 }
開發者ID:remimetral,項目名稱:laravel,代碼行數:38,代碼來源:LangAutoDetection.php

示例11: whitelisted

 static function whitelisted()
 {
     // Detect API Request
     //
     if (Input::get('api_key') && Input::get('user_uid')) {
         if (Config::get('app.api_key') == Input::get('api_key')) {
             if (!User::getIndex(Input::get('user_uid'))) {
                 return false;
             }
             Session::set('user_uid', Input::get('user_uid'));
             return true;
         }
         return false;
     }
     // Detect Whitelisted Route
     //
     foreach (Config::get('app.whitelist') as $pattern) {
         if (is_array($pattern)) {
             if (Request::is(key($pattern))) {
                 return in_array(self::method(), current($pattern));
             }
         } else {
             if (Request::is($pattern)) {
                 return true;
             }
         }
     }
     return false;
 }
開發者ID:pombredanne,項目名稱:open-swamp,代碼行數:29,代碼來源:FiltersHelper.php

示例12: destroy

 public function destroy($id)
 {
     $cart = $this->getCart();
     $cart->remove($id);
     Session::set('cart', $cart);
     return redirect()->route('cart');
 }
開發者ID:joelmartins,項目名稱:laravel_commerce,代碼行數:7,代碼來源:CartController.php

示例13: update

 /**
  * Update the specified resource in storage.
  *
  * @param Request $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $lang = 'en')
 {
     if (array_key_exists($lang, Config::get('languages'))) {
         Session::set('applocale', $lang);
     }
     return Redirect::back();
 }
開發者ID:hungtruongquoc,項目名稱:tripplanner,代碼行數:14,代碼來源:LanguageController.php

示例14: home

 public function home($lang)
 {
     $langs = ['tr', 'en'];
     if (in_array($lang, $langs)) {
         Session::set('lang', $lang);
         return Redirect::back()->with('lang_msg', 'Your Changeing language');
     }
 }
開發者ID:moin35,項目名稱:multilanguage,代碼行數:8,代碼來源:LangController.php

示例15: getCart

 /**
  * @return mixed
  */
 private function getCart()
 {
     if (!Session::has('cart')) {
         Session::set('cart', $this->cart);
     }
     $cart = Session::get('cart');
     return $cart;
 }
開發者ID:kzoty,項目名稱:laravel_commerce,代碼行數:11,代碼來源:CartController.php


注:本文中的Illuminate\Support\Facades\Session::set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。