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


PHP Cookie::forever方法代码示例

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


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

示例1: index

 public function index($lang)
 {
     $cookie = Cookie::forever('lang', $lang);
     $response = Redirect::back();
     $response->withCookie($cookie);
     return $response;
 }
开发者ID:fencer-md,项目名称:stoticlle,代码行数:7,代码来源:LanguageController.php

示例2: dologin

 public function dologin()
 {
     $params = Input::all();
     if (empty($params['username'])) {
         Session::flash('error', '用户名必须填写');
         return Redirect::route('login');
     }
     if (empty($params['password'])) {
         Session::flash('error', '密码必须填写');
         return Redirect::route('login');
     }
     if (empty($params['captcha'])) {
         Session::flash('error', '验证码必须填写');
         return Redirect::route('login');
     }
     if (!$this->_validate_captcha($params['captcha'])) {
         Session::flash('error', '验证码错误');
         return Redirect::route('login');
     }
     $password = md5(md5($params['password']));
     $admin = AdminORM::whereUsername($params['username'])->wherePwd($password)->where('status', '<>', BaseORM::DISABLE)->first();
     if (!empty($admin)) {
         Session::flash('success', '登陆成功');
         $admin_id_cookie = Cookie::forever('admin_id', $admin->id);
         $admin_username_cookie = Cookie::forever('admin_username', $admin->username);
         $k_cookie = Cookie::forever('k', Crypt::encrypt($admin->id . $admin->username));
         $login_time_cookie = Cookie::forever('login_time', time());
         $admin->last_login_time = date('Y-m-d H:i:s');
         $admin->save();
         return Redirect::route('home')->withCookie($k_cookie)->withCookie($admin_id_cookie)->withCookie($admin_username_cookie)->withCookie($login_time_cookie);
     } else {
         Session::flash('error', '用户没找到');
         return Redirect::route('login');
     }
 }
开发者ID:mingshi,项目名称:printer-backend,代码行数:35,代码来源:EntryController.php

示例3: scope_base

 public function scope_base()
 {
     $code = Input::get('code', '');
     $state = Input::get('state', '');
     $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wxe7d58fa8d7ae3416&secret=2204083b829c499d245a46849b2befb2&code=" . $code . "&grant_type=authorization_code";
     try {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
         curl_setopt($ch, CURLOPT_TIMEOUT, 10);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $result = curl_exec($ch);
         curl_close($ch);
         $uri = urldecode($state);
         $res = json_decode($result, TRUE);
         $open_id = $res['openid'];
         $data = callApi('1.0/user/wx/info', ['wx_id' => $open_id]);
         if ($data->status == 'success') {
             if (!empty($data->result)) {
                 $id_cookie = Cookie::forever('user_id', $data->result->id);
                 $open_id_cookie = Cookie::forever('open_id', $open_id);
                 return Redirect::to($uri)->withCookie($id_cookie)->withCookie($open_id_cookie);
             } else {
                 return Redirect::route('forbidden');
             }
         } else {
             return Redirect::route('forbidden');
         }
     } catch (Exception $e) {
         return Redirect::route('forbidden');
     }
 }
开发者ID:mingshi,项目名称:printer-wap,代码行数:33,代码来源:WxController.php

示例4: configureLocale

 /**
  * Detect and set application localization environment (language).
  * NOTE: Don't foreget to ADD/SET/UPDATE the locales array in app/config/app.php!
  *
  */
 private function configureLocale()
 {
     $mLocale = Config::get('app.locale');
     if (!Session::has('locale')) {
         $mFromCookie = Cookie::get('locale', null);
         if ($mFromCookie != null && in_array($mFromCookie, Config::get('app.locales'))) {
             $mLocale = $mFromCookie;
         } else {
             $mFromURI = Request::segment(1);
             if ($mFromURI != null && in_array($mFromURI, Config::get('app.locales'))) {
                 $mLocale = $mFromURI;
             } else {
                 $mFromBrowser = substr(Request::server('http_accept_language'), 0, 2);
                 if ($mFromBrowser != null && in_array($mFromBrowser, Config::get('app.locales'))) {
                     $mLocale = $mFromBrowser;
                 }
             }
         }
         Session::put('locale', $mLocale);
         Cookie::forever('locale', $mLocale);
     } else {
         $mLocale = Session::get('locale');
     }
     App::setLocale($mLocale);
 }
开发者ID:bizcoine,项目名称:ecoinstrader,代码行数:30,代码来源:BaseController.php

示例5: handle

 public function handle(Request $request, \Closure $next)
 {
     if ($request->has('_lang') && ($lang = $request->get('_lang'))) {
         return back()->cookie(\Cookie::forever('a_lc', $lang));
     }
     app()->setLocale($request->cookie('a_lc', config('admin.locale')));
     return $next($request);
 }
开发者ID:mikelmi,项目名称:admin,代码行数:8,代码来源:SetAdminLocale.php

示例6: addCookie

 public function addCookie($sName, $mxValue, $iTime = 0)
 {
     if ($iTime > 0) {
         $this->_aCookies[] = \Cookie::make($sName, $mxValue, $iTime);
     } else {
         $this->_aCookies[] = \Cookie::forever($sName, $mxValue);
     }
 }
开发者ID:laravel-blog,项目名称:laravel51-sandbox,代码行数:8,代码来源:Helper.php

示例7: setCookie

 /**
  * Store data in the cookie.
  *
  * @param string $index
  * @param array $data
  * @param bool|int $period Hours
  *
  * @return bool
  */
 public function setCookie($index, $data, $period = false)
 {
     if (!$this->getCookie($index)) {
         $data = serialize($data);
         if (!$period) {
             \Cookie::forever($index, $data);
         }
     }
     return false;
 }
开发者ID:masikonis,项目名称:laravel-geography,代码行数:19,代码来源:CookieTrait.php

示例8: ChecksiteLogin

 public function ChecksiteLogin()
 {
     if (Input::has('site-password')) {
         if (Input::get('site-password') == Config::get('config.site_password')) {
             $cookie = Cookie::forever('siteprotection', 'YES');
             return Redirect::back()->withCookie($cookie);
         }
     }
     Cookie::forget('siteprotection');
     return Redirect::back()->with(['errors' => 'Sorry wrong password for site.']);
 }
开发者ID:vanderlin,项目名称:halp,代码行数:11,代码来源:PageController.php

示例9: postIndex

 public function postIndex()
 {
     /*$hash=Hash::make(Input::get('password'));
      	echo $hash;
      	die();*/
     if (trim(Input::get('password')) != "" && Auth::attempt(array('mail' => Input::get('mail'), 'password' => Input::get('password')), true)) {
         $cookie = Cookie::forever('avatar', Auth::user()->id);
         return Redirect::to('/')->withCookie($cookie);
     } else {
         return Redirect::to('/login')->with('message', 'Your username/password combination was incorrect')->withInput();
     }
 }
开发者ID:ghyster,项目名称:dns-angular,代码行数:12,代码来源:LoginController.php

示例10: getIdentifier

 private function getIdentifier()
 {
     $idt = '';
     if (!Sentry::check()) {
         if (!Cookie::has('Anon_Cart_Extension')) {
             Cookie::forever('Anon_Cart_Extension', get_unique_id());
         }
         $idt = Cookie::get('Anon_Cart_Extension');
     } else {
         $idt = Sentry::user()->id;
     }
     return $idt;
 }
开发者ID:CSFix,项目名称:L3-Eticaret,代码行数:13,代码来源:cart.php

示例11: getLogin

 public function getLogin()
 {
     $fb = OAuth::consumer('Facebook');
     if (Input::get('code')) {
         $token = $fb->requestAccessToken(Input::get('code'));
         $user = json_decode($fb->request('/me'), true);
         $user['oauth_provider'] = 'facebook';
         $user['access_token'] = $token->getAccessToken();
         $uid = $this->_saveUser($user);
         return Redirect::to('index')->withCookie(Cookie::forever('uid', $uid));
     } else {
         $user = $this->_getUser();
         if ($user) {
             return Redirect::to('index');
         } else {
             return View::make('ttwwoo.login')->with('loginUrl', $fb->getAuthorizationUri()->getAbsoluteUri());
         }
     }
 }
开发者ID:sahilsarpal15,项目名称:ttwwoo,代码行数:19,代码来源:TtwwooController.php

示例12: login

 public function login()
 {
     $admin = \Neyko\Admin\Model\Administrator::where("username", "=", \Input::get('username'))->first();
     if ($admin) {
         if (\Hash::check(\Input::get('password'), $admin->password)) {
             \Session::put('admin', $admin->id);
             if (\Input::get("remember_me") == "on") {
                 $admin->remember_token = str_random(100);
                 $admin->save();
                 return redirect('/admin')->with('message', 'You have successfully logged in.')->withCookie(\Cookie::forever('neyko_admin_remember_token', $admin->remember_token));
             } else {
                 return redirect('/admin')->with('message', 'You have successfully logged in.');
             }
         } else {
             return redirect('/admin/login')->with('message', 'You have failed to login.');
         }
     } else {
         return redirect('/admin/login')->with('message', 'You have failed to login.');
     }
 }
开发者ID:neyko5,项目名称:mkmscraper,代码行数:20,代码来源:AdministratorController.php

示例13: getCallback

 public function getCallback()
 {
     try {
         $session = $this->helper->getSessionFromRedirect();
     } catch (FacebookRequestException $ex) {
         // When Facebook returns an error
     } catch (\Exception $ex) {
         // When validation fails or other local issues
     }
     if ($session) {
         $request = new FacebookRequest($session, 'GET', '/me');
         $response = $request->execute();
         $fbuser = $response->getGraphObject();
         if ($fbuser) {
             return Redirect::to('/facebook/checkuser')->with('sessionfb', $session)->with('userfb', $fbuser)->withCookie(Cookie::forever('user', $fbuser));
         } else {
             dd('Error');
         }
     }
 }
开发者ID:NhuanTDBK,项目名称:Bluemix-Laravel-Demo,代码行数:20,代码来源:FaceBookController.php

示例14: doAgegate

 /**
  * Processes the date of birth submitted in the age gate form
  */
 public function doAgegate()
 {
     $previousTooYoung = \Session::get('laravel-agegate.previous_too_young');
     if ($previousTooYoung) {
         return \Redirect::action('Fbf\\LaravelAgegate\\AgegateController@agegate');
     }
     // Get the date of birth that the user submitted
     $dob = null;
     if (\Input::has('dob')) {
         // field name is dob when using input type date
         $dob = \Input::get('dob');
     } elseif (\Input::has('dob_year') && \Input::has('dob_month') && \Input::has('dob_day')) {
         // field name has _year, _month and _day components if input type select
         $dob = \Input::get('dob_year') . '-' . \Input::get('dob_month') . '-' . \Input::get('dob_day');
     }
     $maxDob = Carbon::now()->subYears(\Config::get('laravel-agegate::minimum_age'))->addDay()->toDateString();
     $validator = \Validator::make(array('dob' => $dob), array('dob' => 'required|date|date_format:Y-m-d|before:' . $maxDob), \Lang::get('laravel-agegate::validation.custom'));
     if ($validator->fails()) {
         $failed = $validator->failed();
         $validExceptTooYoung = array_get($failed, 'dob.Before');
         $canTryAgain = \Config::get('laravel-agegate::can_try_again');
         if ($validExceptTooYoung && !$canTryAgain) {
             \Session::put('laravel-agegate.previous_too_young', true);
         } else {
             \Session::keep('url.intended');
         }
         return \Redirect::action('Fbf\\LaravelAgegate\\AgegateController@agegate')->withErrors($validator)->withInput();
     }
     if (\Config::get('laravel-agegate::cookie_age') == 'forever') {
         // Set a forever cookie saying the user is old enough
         $cookie = \Cookie::forever(\Config::get('laravel-agegate::cookie_name'), \Config::get('laravel-agegate::cookie_val'));
     } elseif (is_int(\Config::get('laravel-agegate::cookie_age'))) {
         // Sets a cookie lasting X minutes saying the user is old enough
         Cookie::make(\Config::get('laravel-agegate::cookie_name'), \Config::get('laravel-agegate::cookie_val'), \Config::get('laravel-agegate::cookie_age'));
     } else {
         // Sets a session cookie saying the user is old enough
         $cookie = \Cookie::make(\Config::get('laravel-agegate::cookie_name'), \Config::get('laravel-agegate::cookie_val'));
     }
     return \Redirect::intended('/')->withCookie($cookie);
 }
开发者ID:fbf,项目名称:laravel-agegate,代码行数:43,代码来源:AgegateController.php

示例15: getLogin

 public function getLogin()
 {
     if ($remember = Cookie::get('_user_remember')) {
         $auth_token = Crypt::decrypt($remember);
         $auth_token = explode(':', $auth_token);
         $authed = User::authenticateUser($auth_token[0], $auth_token[1]);
         if (is_object($authed)) {
             if (isset($_REQUEST['remember'])) {
                 Cookie::forever('_user_remember', Crypt::encrypt($email . ':' . $md5pass));
             }
             Session::put('user', $authed);
             return Redirect::action('PortalController@getIndex');
         } else {
             logr(array('data' => $_REQUEST, 'time' => date('Y-m-d H:i:s')), 'failed-logins');
             return View::make('launch.login', array('validation' => 'Your password has recently changed. Please login again.'));
         }
     }
     if (Session::has('user')) {
         return Redirect::action('PortalController@getIndex');
     }
     return View::make('launch.login', array('validation' => Session::get('validation')));
 }
开发者ID:jacobross85,项目名称:community,代码行数:22,代码来源:LaunchController.php


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