当前位置: 首页>>代码示例>>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;未经允许,请勿转载。