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


PHP Cookie::put方法代码示例

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


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

示例1: login

 public function login($username = NULL, $password = NULL, $remember = FALSE)
 {
     if (!$username && !$password && $this->exists()) {
         // Logs user in when the cookie hash value is matching the one in the database.
         // Logs user in
         Session::put($this->_sessionName, $this->data()->id);
     } else {
         $user = $this->find($username);
         if ($user) {
             if ($this->data()->password === Hash::make($password, $this->_data->salt)) {
                 Session::put($this->_sessionName, $this->data()->id);
                 if ($remember) {
                     $hash = Hash::unique();
                     $hashCheck = $this->_db->get('users_session', array('user_id', '=', $this->data()->id));
                     if (!$hashCheck->count()) {
                         $this->_db->insert('users_session', array('user_id' => $this->data()->id, 'hash' => $hash));
                     } else {
                         $hash = $hashCheck->first()->hash;
                     }
                     Cookie::put($this->_cookieName, $hash, Config::get('remember/cookie_expiry'));
                 }
                 return TRUE;
             }
         }
     }
     return false;
 }
开发者ID:kamilik26,项目名称:OOP_login,代码行数:27,代码来源:User.php

示例2: login

 public static function login($username = null, $password = null, $remember = null)
 {
     if ($username != null && $password != null) {
         $class = Config::get('user/user_class');
         $user = $class::find($username, Config::get('user/userField'));
         //echo '<pre>';
         //var_dump($user);
         //echo '</pre>';
         //die();
         if ($user != null) {
             if ($user->{Config::get('user/passwordField')} === Hash::make($password)) {
                 //Estas Dos Lineas Loguean realmente al Usuario
                 Session::put(Config::get('session/session_name'), $user);
                 Session::put('isLoggedIn', true);
                 if (Config::get('groups/active')) {
                     Session::put('listPermission', self::getPermissions($user));
                 }
                 if ($remember && Config::get('session/active')) {
                     $hash = Hash::unique();
                     $hashCheck = DB::getInstance()->table(Config::get('session/table'))->where(Config::get('session/primaryKey'), $user->{$user->getInfo('primaryKey')})->first();
                     if ($hashCheck == null) {
                         DB::getInstance()->table(Config::get('session/table'))->insert([Config::get('session/primaryKey') => $user->{$user->getInfo('primaryKey')}, Config::get('session/hashField') => $hash]);
                     } else {
                         $hash = $hashCheck->{Config::get('session/hashField')};
                     }
                     Cookie::put(Config::get('remember/cookie_name'), $hash, Config::get('remember/cookie_expiry'));
                 }
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:goldenSniperOS,项目名称:api-participo,代码行数:33,代码来源:Auth.php

示例3: login

 public function login($username = null, $password = null, $remember = false)
 {
     //print_r($this->_data);
     if (!$username && !$password && $this->exists()) {
         //Log User In by setting a session
         Session::put($this->_sessionName, $this->data()->id);
     } else {
         $user = $this->find($username);
         if ($user) {
             if ($this->data()->password === Hash::make($password, $this->data()->salt)) {
                 Session::put($this->_sessionName, $this->data()->id);
                 //If  user has clicked 'remember', this code below iis going to be run
                 if ($remember) {
                     $hash = Hash::unique();
                     $hashCheck = $this->_db->get('users_session', array('user_id', '=', $this->data()->id));
                     if (!$hashCheck->count()) {
                         $this->_db->insert('users_session', array('user_id' => $this->data()->id, 'hash' => $hash));
                     } else {
                         $hash = $hashCheck->first()->hash;
                     }
                     Cookie::put($this->_cookieName, $hash, Config::get('remember/cookie_expiry'));
                 }
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:bqevin,项目名称:ivertise-stocker,代码行数:28,代码来源:User.php

示例4: login

 public function login($username = NULL, $password = NULL, $remember = FALSE)
 {
     $user = $this->find($username);
     if (!$username && !$password && $this->exists()) {
         Session::put($this->_sessionName, $this->data()->id);
     } else {
         if ($user) {
             if ($this->data()->password === Hash::make($password, $this->data()->salt)) {
                 Session::put($this->_sessionName, $this->data()->id);
                 if ($remember) {
                     $hash = Hash::unique();
                     // Check if a Hash is stored in the database in the table "users_session"
                     $hashCheck = $this->_db->get('users_session', array('user_id', '=', $this->data()->id));
                     // if no Hash is found in the table "users_session", insert a Hash with the hash that is generated above.
                     if (!$hashCheck->count()) {
                         $this->_db->insert('users_session', array('user_id' => $this->data()->id, 'hash' => $hash));
                     } else {
                         // If a Hash is FOUND in the table "users_session" store the HASH value in the variable $hash.
                         $hash = $hashCheck->first()->hash;
                     }
                     Cookie::put($this->_cookieName, $hash, Config::get('remember/cookie_expiry'));
                 }
                 return TRUE;
             }
         }
     }
     return FALSE;
 }
开发者ID:muhdrazi,项目名称:OOP_login4,代码行数:28,代码来源:User.php

示例5: Authenticate

 public function Authenticate($Username = false, $Password = false, $Remember = false)
 {
     if ($Username !== false && $Password !== false) {
         //Confirm Input
         $UserData = DB::getInstance()->table("Users")->where("Username", $Username)->get(1)[0];
         $HashedPassAttempt = Hash::make(Input::get("Password"), $UserData->Salt);
         if ($HashedPassAttempt == $UserData->Password) {
             Session::put("UserID", $UserData->UserID);
             if ($Remember == 'on') {
                 //Was Remember Me Checkbox ticked?
                 $hashCheck = DB::getInstance()->table("user_sessions")->where('user_id', $UserData->UserID)->get();
                 //Check for existing session
                 if (count($hashCheck) == 0) {
                     //If there is not an existing hash
                     $hash = Hash::unique();
                     DB::getInstance()->table('user_sessions')->insert(array('user_id' => $UserData->UserID, 'hash' => $hash));
                 } else {
                     //use existing hash if found
                     $hash = $hashCheck[0]->hash;
                 }
                 $Cookie = Cookie::put(Config::get("remember/cookie_name"), $hash, Config::get("remember/cookie_expiry"));
                 //Set cookie
             }
             return $this->form($UserData->UserID);
             //Return User MetaTable
         } else {
             throw new Exception('Invalid Username or Password');
         }
     } else {
         throw new Exception('Invalid Username or Password');
     }
     return false;
 }
开发者ID:25564,项目名称:Resume,代码行数:33,代码来源:User.php

示例6: login

 public function login($username = null, $password = null, $remember = false)
 {
     if (!$username && !$password && $this->exists()) {
         Session::put($this->_sessionName, $this->data()->id);
         return true;
     } else {
         if ($username && $password) {
             $user = $this->find($username);
             if ($user) {
                 if ($this->data()->password === Hash::make($password, $this->data()->salt)) {
                     // Check if the user account is activated
                     if ((int) $this->data()->active == 0) {
                         throw new Exception(lang('ACCOUNT_INACTIVATED'));
                         return false;
                     }
                     Session::put($this->_sessionName, $this->data()->id);
                     if ($remember) {
                         $hash = Hash::unique();
                         $hashCheck = $this->_db->get('users_session', array('user_id', '=', $this->data()->id));
                         if (!$hashCheck->count()) {
                             $this->_db->insert('users_session', array('user_id' => $this->data()->id, 'hash' => $hash));
                         } else {
                             $hash = $hashCheck->first()->hash;
                         }
                         Cookie::put($this->_cookieName, $hash, Config::get('remember/cookie_expiry'));
                     }
                     return true;
                 }
             }
         }
     }
     throw new Exception("Incorrect Username/password.");
     return false;
 }
开发者ID:andersoonluan,项目名称:PHP,代码行数:34,代码来源:user.php

示例7: authorize

 public function authorize($login, $password, $remember)
 {
     $config = Service::get('config');
     $db = Service::get('pdo');
     $query = $db->prepare("SELECT * FROM `user` WHERE `email`= :email AND `password`= :password");
     $query->execute(array(':email' => $login, ':password' => md5($password)));
     $user = $query->fetchObject();
     $userid = $user->id;
     if ($user->password === md5($password)) {
         if ($remember === 'on') {
             $hash = hash('sha256', uniqid());
             $hashcheck = $user->hash;
             if (!$hashcheck) {
                 $query = $db->prepare("UPDATE `user` SET `hash` = :hash WHERE `id` = :id");
                 $query->execute(array(':hash' => $hash, ':id' => $userid));
             } else {
                 $hash = $user->hash;
             }
             Cookie::put($config->getVal('remember/cookie_name'), $hash, $config->getVal('remember/cookie_expiry'));
         }
         if ($userid) {
             $this->user = $user;
             $session = Service::get('session');
             $session->set($config->getVal('session/session_name'), $userid);
         }
         return $userid;
     }
 }
开发者ID:JavaTrain,项目名称:train,代码行数:28,代码来源:User.php

示例8: __construct

 public function __construct($user = null)
 {
     $this->_db = DB::getInstance();
     $this->session_name = Config::get('session/session_name');
     $this->_cookieName = Config::get('remember/cookie_name');
     if (!$user) {
         if (Session::exists($this->session_name)) {
             if ($this->find_by_id(Session::get($this->session_name))) {
                 $this->_isLoggedIn = true;
             } else {
                 // logout process
                 $this->logout();
             }
         } elseif (Cookie::exists($this->_cookieName)) {
             $this->_db->get('user_id', 'users_session', array('hash', '=', Cookie::get($this->_cookieName)));
             if ($this->find_by_id($this->_db->first()->user_id)) {
                 Session::put($this->session_name, $this->data()->id);
                 Cookie::put($this->_cookieName, Cookie::get($this->_cookieName), Config::get('remember/cookie_expiry'));
                 Session::flash('success', 'Wellcome Back ' . $this->data()->username);
                 $this->_isLoggedIn = true;
             } else {
                 $this->logout();
             }
         }
     } elseif (is_numeric($user)) {
         if ($this->find_by_id($user)) {
             Session::put($this->session_name, $this->data()->id);
             $this->_isLoggedIn = true;
         } else {
             $this->logout();
         }
     } elseif (is_string($user)) {
         return $this->find($user);
     }
 }
开发者ID:shaheen13,项目名称:origin,代码行数:35,代码来源:User.php

示例9: login

 /**
  * Description
  * @param string $email
  * @param string $password
  * @param boolean $remember
  * @return boolean
  */
 public function login($email = null, $password = null, $remember = false)
 {
     if ($email === null && $password === null && $this->exists()) {
         Session::put(Config::get('session/name'), $this->data()->id);
     } else {
         $employeeExists = $this->find($email);
         $passwordCheck = password_verify($password, $this->data()->password_hash);
         if ($employeeExists && $passwordCheck) {
             Session::put(Config::get('session/name'), $this->data()->id);
             if ($remember) {
                 /**
                  * this additional check accounts for possibility that old session
                  * hash hasn't been deleted from database so that same employee won't
                  * be inserted in employee_session table twice
                  **/
                 $oldRecord = $this->database->get('employee_session', ['employee_id', '=', $this->data()->id]);
                 if ($oldRecord->count()) {
                     $hash = $oldRecord->first()->hash;
                 } else {
                     $hash = bin2hex(openssl_random_pseudo_bytes(32));
                     $this->database->insert('employee_session', ['employee_id' => $this->data()->id, 'hash' => $hash]);
                 }
                 Cookie::put(Config::get('cookie_to_remember_employee_session/name'), $hash, Config::get('cookie_to_remember_employee_session/exptime'));
             }
             return true;
         }
     }
     return false;
 }
开发者ID:adiachenko,项目名称:booker,代码行数:36,代码来源:Employee.php

示例10: forceLogin

 public static function forceLogin($user = null, $remember = false)
 {
     if ($user->exists()) {
         DB::instance()->delete("user_sessions", array("", "hash", "=", Cookie::get(Config::get('remember/cookie_name'))));
         Session::put(Config::get('session/loggedId'), $user->id());
         if ($remember) {
             $hash = Hash::hashUnique();
             DB::instance()->insert("user_sessions", array('user_id' => $user->id(), 'hash' => $hash, 'expiry' => DateFormat::sql(time() + Config::get('remember/cookie_expiry'))));
             Cookie::put(Config::get('remember/cookie_name'), $hash, Config::get('remember/cookie_expiry'));
         }
         self::$_currentUser = new User();
     }
 }
开发者ID:Wicloz,项目名称:UniversityWebsite,代码行数:13,代码来源:Users.php

示例11: Create

 public static function Create($Key = 0, $Company = false)
 {
     $Return = false;
     if ($Key !== 0) {
         if (\Session::exists("refKey")) {
             if (\Session::get("refKey") != $Key) {
                 //This computer has multiple Keys? I'm not sure how or why this would happen.
                 //It is a possibility so I guess I should probably plan for it
                 $SavedKey = new Key(\Session::get("refKey"));
                 if ($SavedKey->validKey()) {
                     //Has two valid keys? What on earth? I will have to account for this later
                 } else {
                     \Session::put("refKey", $Key);
                     $Return = true;
                 }
             }
         } else {
             \Session::put("refKey", $Key);
             $Return = true;
         }
         if (\Cookie::exists("refKey")) {
             if (\Cookie::get("refKey") != $Key) {
                 $SavedKey = new Key(\Cookie::get("refKey"));
                 if ($SavedKey->validKey()) {
                     //Has two valid keys? What on earth? I will have to account for this later
                 } else {
                     \Cookie::put("refKey", $Key, \Config::get("tracking/cookie_expiry"));
                     $Return = true;
                 }
             }
         } else {
             \Cookie::put("refKey", $Key, \Config::get("tracking/cookie_expiry"));
             $Return = true;
         }
         if ($Company != false) {
             if (count(\DB::getInstance()->table("companyip")->where("IP", \Connection::IP())->where("Company", $Company->ID())) == 0) {
                 \DB::getInstance()->table("companyip")->insert(array("IP" => \Connection::IP(), "Company" => $Company->ID(), "LastScene" => \Time::get(), "Hits" => 1));
             } else {
                 \DB::getInstance()->table("companyip")->where("IP", \Connection::IP())->increment("Hits");
             }
         }
         //IP Based Search will go here
         return $Return;
     }
     return false;
 }
开发者ID:25564,项目名称:Resume,代码行数:46,代码来源:Tracker.php

示例12: post_test

 public function post_test()
 {
     if (Auth::guest()) {
         Cookie::put('sapoc_new_offer', json_encode(Input::get()), 30, '/', URL::base());
         Log::info('Cookied');
     }
     // $creds = array(
     //     'username' => Input::get('email'),
     //     'password' => Input::get('password')
     // );
     // if (Auth::attempt($creds)) {
     // 	echo 'Data saved';
     // } else {
     // 	return Redirect::to('ref/test')
     // 			->with_input()
     // 			->with('login_errors', true);
     // }
 }
开发者ID:rooslunn,项目名称:sapoc,代码行数:18,代码来源:ref.php

示例13: authenticate

 public function authenticate()
 {
     // Create an consumer from the config
     $consumer = Consumer::make($this->config);
     // Load the provider
     $provider = Provider::make($this->provider);
     // Create the URL to return the user to
     $callback = array_get($this->config, 'callback') ?: \URL::to(\Config::get('oneauth::urls.callback', 'connect/callback'), null, false, false);
     $callback = rtrim($callback, '/') . '/' . $this->provider;
     // Add the callback URL to the consumer
     $consumer->callback($callback);
     // Get a request token for the consumer
     $token = $provider->request_token($consumer);
     // Store the token
     \Cookie::put('oauth_token', base64_encode(serialize($token)));
     // Redirect to the twitter login page
     return \Redirect::to($provider->authorize_url($token, array('oauth_callback' => $callback)));
 }
开发者ID:marmaray,项目名称:OLD-laravel-France-website,代码行数:18,代码来源:oauth.php

示例14: action_new_post

 public function action_new_post()
 {
     if (Auth::guest()) {
         $page = Input::get('offer_type') == 1 ? 'offers/new_freight' : 'offers/new_trans';
         Cookie::put('rid', $page);
         return Redirect::to('login')->with_input();
     }
     $input = array('user_id' => Input::get('user_id'), 'offer_type' => Input::get('offer_type'), 'from_date' => $this->mysql_date(Input::get('from_date')), 'to_date' => $this->mysql_date(Input::get('to_date')), 'from_country' => Input::get('from_country'), 'from_state' => Input::get('from_state'), 'from_town' => Input::get('from_town'), 'to_country' => Input::get('to_country'), 'to_state' => Input::get('to_state'), 'to_town' => Input::get('to_town'), 'auto_type' => Input::get('auto_type'), 'auto_load_type' => Input::get('auto_load_type'), 'auto_capacity' => Input::get('auto_capacity'), 'auto_volume' => Input::get('auto_volume'), 'auto_price' => Input::get('auto_price'), 'auto_count' => Input::get('auto_count'), 'auto_license' => Input::get('auto_license'), 'comments' => Input::get('comments'));
     $rules = array('offer_type' => 'required', 'from_date' => 'required', 'to_date' => 'required', 'from_country' => 'required', 'from_town' => 'required', 'to_country' => 'required', 'to_town' => 'required', 'auto_type' => 'required', 'auto_capacity' => 'numeric|required', 'auto_count' => 'integer', 'auto_price' => 'numeric');
     $v = Validator::make($input, $rules);
     if ($v->fails()) {
         $page = $input['offer_type'] == 1 ? 'offers/new_freight' : 'offers/new_trans';
         return Redirect::to($page)->with_errors($v)->with_input();
     } else {
         $offer = new Offer($input);
         $offer->save();
         return View::make('sapoc.pages.result')->with('message', __('offers-new.save-success'));
     }
 }
开发者ID:rooslunn,项目名称:sapoc,代码行数:19,代码来源:offers.php

示例15: setScore

 public function setScore($id, $hiscore)
 {
     switch ($this->_result) {
         //switch through cases of result
         case 'won':
             //if won
             $score = Cookie::get('score');
             //get current score from cookie
             Cookie::put('score', $score + 1, time() + 60 * 60 * 24);
             //reset cookie score +1 value
             break;
         case 'lost':
             //if lost
             Cookie::put('score', 0, time() + 60 * 60 * 24);
             //set cookie score to 0
             break;
             //no need for tied, because nothing happens to score
     }
     if ($hiscore < Cookie::get('score')) {
         //if user's hiscore is less than current score
         $this->_db->update('users', $id, array('hiscore' => Cookie::get('score')));
     }
 }
开发者ID:rafalstapinski,项目名称:rps,代码行数:23,代码来源:Game.php


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