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


PHP cookie::put方法代碼示例

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


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

示例1: login

 public function login($username = null, $password = null, $remember = false)
 {
     if (!$username && !$password && $this->exists()) {
         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('user_session', array('user_id', '=', $this->data()->id));
                     if (!$hashCheck->count()) {
                         $this->_db->insert('user_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:hatemali510,項目名稱:carservice,代碼行數:25,代碼來源:user.php

示例2: login

 public function login($UserID = null, $Password = null, $remember = false)
 {
     // $user=$this->find($UserID);
     if (!$UserID && !$Password && $this->exists()) {
         session::put($this->_sessionName, $this->data());
     } else {
         $user = $this->find($UserID);
         // print_r($user);
         // print_r($this->_data);
         if ($user) {
             if ($this->data()->Password === hash::make($Password)) {
                 echo 'ok!';
                 // need to check the node_id/UserID
                 session::put($this->_sessionName, $this->data()->node_id);
                 if ($remember) {
                     $hash = hash::unique();
                     $hashCheck = $this->_database->get('User_session', array('UserID', '=', $this->data()->node_id));
                     if (!$hashCheck->counts()) {
                         $this->_database->insert('User_session', array('userID' => $this->data()->SessionID, 'Hash' => $hash));
                     } else {
                         $hash = $hashCheck->first()->hash;
                     }
                     cookie::put($this->_cookieName, $hash, config::get('remember/cookie_expiry'));
                 }
                 return true;
             }
         }
     }
     return false;
 }
開發者ID:pediredla,項目名稱:SocialNetwork,代碼行數:30,代碼來源:user.php

示例3: login

 public function login($username = null, $password = null, $remember = false)
 {
     if (!$username && !$password && $this->exists()) {
         //if no username or password sent to function and there is a user in database, used when remeber function is active
         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) {
                     //if remeber option selected
                     $hash = hash::unique();
                     $hashCheck = $this->_db->get('User_Sessions', array('User_Id', '=', $this->data()->Id));
                     //check whether user session saved on db
                     if (!$hashCheck->counts()) {
                         $this->_db->insert('User_Sessions', array('User_Id' => $this->data()->Id, 'Hash' => $hash));
                     } else {
                         $hash = $hashCheck->first()->Hash;
                         //if already in session db use that hash (should not happen)
                     }
                     cookie::put($this->_cookieName, $hash, config::get('remember/cookie_expiry'));
                     //create login cookie
                 }
                 return true;
             } else {
                 $this->_log->warning('Wrong  password used for user: ' . $username);
                 // Will be logged
                 echo "Sorry, password is incorrect. Please try again. ";
             }
         } else {
             //	var_dump($logger);
             $this->_log->warning('Wrong username used: ' . $username);
             // Will be logged
             echo "Sorry, username not found. ";
         }
     }
     //end of not remember
     return false;
 }
開發者ID:jdupreez1,項目名稱:smartpoint,代碼行數:40,代碼來源:user.php


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