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


PHP Request::hasCookie方法代碼示例

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


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

示例1: getModel

 public function getModel()
 {
     if (\Auth::check()) {
         return \Auth::user();
     }
     if ($this->request->hasCookie('email_user')) {
         $user = Email::where('email', $this->request->cookie('email_user'));
     }
     if ($this->request->hasCookie('guest_user')) {
         $tracker = $this->request->cookie('guest_user');
     }
     $tracker = $this->request->getClientIp();
     $user = Guest::firstOrCreate(['identifier' => $tracker]);
     return $user;
 }
開發者ID:codeforpg,項目名稱:PostIt,代碼行數:15,代碼來源:GetIdentity.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  *
  * @throws \Symfony\Component\HttpKernel\Exception\HttpException
  */
 public function handle(Request $request, Closure $next)
 {
     if ($this->app->isDownForMaintenance() && !in_array($request->getClientIp(), config('maintenance.ips', [])) && (config('maintenance.bypass_with_cookie', false) === false || config('maintenance.cookie_name', '') === '' || !$request->hasCookie(config('maintenance.cookie_name')))) {
         throw new HttpException(503);
     }
     return $next($request);
 }
開發者ID:philcross,項目名稱:laravel-maintenance-mode,代碼行數:16,代碼來源:CheckForMaintenanceMode.php

示例3: handle

 public function handle(Request $request, Closure $next)
 {
     if ($request->hasCookie('lang')) {
         app()->setLocale($request->cookie('lang'));
     }
     return $next($request);
 }
開發者ID:gubenkovalik,項目名稱:vgchat,代碼行數:7,代碼來源:Locale.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->hasCookie('token')) {
         return redirect(route('login'))->withErrors(['generic' => ['You need to be logged in']])->withCookie(cookie('token', $request->cookie('token'), -1, null, null, false, true));
     }
     return $next($request);
 }
開發者ID:shauno,項目名稱:sesh.co.za,代碼行數:14,代碼來源:CheckIfTokenSet.php

示例5: getLocale

 /**
  * {@inheritdoc}
  */
 public function getLocale()
 {
     if ($this->request->hasCookie('locale')) {
         return $this->request->cookie('locale');
     } else {
         return $this->getConfigDefaultLocale();
     }
 }
開發者ID:stevebauman,項目名稱:translation,代碼行數:11,代碼來源:Translation.php

示例6: findOrCreateTrackingCookieToken

 /**
  * @return string $cookieToken
  */
 protected function findOrCreateTrackingCookieToken()
 {
     $cookieToken = str_random(40);
     if ($this->request->hasCookie(config('footprints.cookie_name'))) {
         $cookieToken = $this->request->cookie(config('footprints.cookie_name'));
     }
     $this->response->withCookie(cookie(config('footprints.cookie_name'), $cookieToken, config('footprints.attribution_duration')));
     return $cookieToken;
 }
開發者ID:KriiV,項目名稱:Footprints,代碼行數:12,代碼來源:CaptureAttributionDataMiddleware.php

示例7: index

 /**
  * Display a listing of the resource.
  *
  * @param Request $request
  * @return Response
  */
 public function index(Request $request)
 {
     /**
      * Check if intro cookie is set
      */
     if (!$request->hasCookie('intro')) {
         return view('in');
     }
     return view('index');
 }
開發者ID:SkysoulDesign,項目名稱:TempArk,代碼行數:16,代碼來源:HomeController.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->hasCookie('uuid')) {
         return $next($request);
     } else {
         $uuid = Uuid::uuid4();
         $response = $next($request);
         return $response->withCookie(cookie()->forever('uuid', $uuid));
     }
 }
開發者ID:alerj,項目名稱:edemocracia,代碼行數:18,代碼來源:UUIDMiddleware.php

示例9: landing

 /**
  * This route is only valid for multi locale applications.
  *
  * @param Request $request
  * @param AccountManager $manager
  * @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse
  */
 public function landing(Request $request, AccountManager $manager)
 {
     if ($manager->account()->locales->count() == 1) {
         return redirect()->to(store_route('store.home'));
     }
     if ($request->hasCookie('locale')) {
         return redirect()->to(store_route('store.home', [], [], $request->cookie('locale')));
     }
     return $this->theme->render('home.landing');
 }
開發者ID:jaffle-be,項目名稱:framework,代碼行數:17,代碼來源:WelcomeController.php

示例10: handle

 /**
  * @param Request $request
  * @param Closure $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     $shop = App::make('Shop');
     if ($request->hasCookie($shop->getSession()->getCookieName()) && $shop->getCart()->has(Cookie::get($shop->getSession()->getCookieName()))) {
         $shop->getCart()->updateExpire();
         return $next($request);
     } else {
         $hash = $shop->getSession()->genId();
         $shop->getCart()->create($hash);
         $shop->getSession()->create($hash);
         $response = $next($request);
         return $response->withCookie(cookie()->make($shop->getSession()->getCookieName(), $hash, $shop->getSession()->getCookieExpire()));
     }
 }
開發者ID:stdsync,項目名稱:laravel-shop,代碼行數:19,代碼來源:ShopSessionMiddleware.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->hasCookie('token')) {
         //if we have a token, the user has been authed at some point
         $jwt = explode('.', $request->cookie('token'));
         //no need to validate signature, we just want the expirey
         $payload = json_decode(base64_decode($jwt[1]));
         if (time() >= $payload->exp) {
             //token has expired, logout
             //TODO, consider checking if refresh has expired too, and auto renew token seamlessly for user
             //TODO, is there a better way to remove cookie and redirect in L5 ->cookie->remove() did seem to work?
             return redirect(route('login'))->withErrors(['generic' => ['Your session has expired, please login again']])->withCookie(cookie('token', $request->cookie('token'), -1, null, null, false, true));
         }
     }
     return $next($request);
 }
開發者ID:shauno,項目名稱:sesh.co.za,代碼行數:23,代碼來源:CheckClientJwtToken.php

示例12: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Auth::check()) {
         // If logged in, take the user's language setting
         $language = Auth::user()->language;
     } else {
         // If not logged in, rely on cookies
         if ($request->hasCookie('locale')) {
             // If cookie exists, use it
             $language = $request->cookie('locale');
         } else {
             // Otherwise, English is our default language
             $language = 'en';
         }
     }
     return $next($request)->withCookie(cookie()->forever('locale', $language));
 }
開發者ID:TheJokersThief,項目名稱:Eve,代碼行數:24,代碼來源:TranslationMiddleware.php

示例13: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // If we do not have a logged in user, check for an authorized JWT
     if (!Auth::check()) {
         // If there is a JWT cookie, grab it
         if ($request->hasCookie('jwt')) {
             $jwt = $request->cookie('jwt');
             // If the JWT is not null, and is too long to be an error message, try to retrieve a user from it
             if ($jwt != null && strlen($jwt) > 35) {
                 try {
                     $user = JWTAuth::toUser($jwt);
                 } catch (JWTException $e) {
                     $user = null;
                 }
                 // If the JWT was valid, and a user was returned from it, log them in
                 if ($user instanceof User) {
                     Auth::login($user);
                 }
             }
         }
     }
     return $next($request);
 }
開發者ID:wyrover,項目名稱:laravel-self-consuming-api-starter,代碼行數:30,代碼來源:LoginUserFromToken.php

示例14: store

 /**
  * Creates a new user.
  * This is a generic user.store function adapted from a previous project
  * and should definitely be brought up to date with this project /
  * adapted so that we can use Laravel Socialite with it.
  *
  *
  * 	Data should be POSTed to this function only
  * @return REDIRECT home
  */
 public function store(Request $request)
 {
     // Only allow following fields to be submitted
     $data = Request::only(['name', 'password', 'password_confirmation', 'email', 'username', 'bio', 'city', 'country']);
     if ($request->hasFile('profile_picture')) {
         $data['profile_picture'] = MediaController::uploadImage($request->file('profile_picture'), time(), $directory = "user", $bestFit = true, $fitDimensions = [500, 500]);
     }
     // Validate all input
     $validator = Validator::make($data, ['name' => 'required', 'email' => 'email|required|unique:users', 'password' => 'required|confirmed|min:5', 'username' => 'required|unique:users|min:4']);
     if ($validator->fails()) {
         // If validation fails, redirect back to
         // registration form with errors
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $data['language'] = $request->hasCookie('locale') ? $request->cookie('locale') : 'en';
     $newUser = createUser($data);
     if ($newUser) {
         Auth::login($newUser);
         // If successful, go to home
         return Redirect::route('home');
     }
     // If unsuccessful, return with errors
     return Redirect::back()->withErrors(['message' => 'We\'re sorry but registration failed, please try again later.'])->withInput();
 }
開發者ID:TheJokersThief,項目名稱:Eve,代碼行數:34,代碼來源:UserController.php

示例15: fromCookie

 public function fromCookie(Request $request)
 {
     $this->setLocale($request->cookie('settings_locale'));
     $this->setCountry($request->cookie('settings_country'));
     $this->setTimezone($request->cookie('settings_timezone'));
     $this->setCurrency($request->cookie('settings_currency'));
     $this->setNumberFormat($request->cookie('settings_number_format'));
     $this->setFirstDayOfWeek($request->cookie('settings_first_day_of_week'));
     $this->setLongDateFormat($request->cookie('settings_long_date_format'));
     $this->setShortDateFormat($request->cookie('settings_short_date_format'));
     $this->setLongTimeFormat($request->cookie('settings_long_time_format'));
     $this->setShortTimeFormat($request->cookie('settings_short_time_format'));
     return $request->hasCookie('settings_locale');
 }
開發者ID:linhntaim,項目名稱:katniss,代碼行數:14,代碼來源:Settings.php


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