示例#1
0
 /**
  * Change the Framework Language.
  */
 public function change($language)
 {
     // Only set language if it's in the Languages array
     if (preg_match('/[a-z]/', $language) && in_array($language, CoreLanguage::$codes)) {
         Session::set('language', ucfirst($language));
         // Store the current Language into Cookie.
         Cookie::set(PREFIX . 'language', $language);
     }
     Url::redirect();
 }
示例#2
0
 public function navigationReload()
 {
     Cookie::set('navigation', $_POST['status']);
 }
示例#3
0
 /**
  * Creates a new cookie for the provided username and sets cookie
  * @param string $username
  */
 private function newCookie($username, $rememberme)
 {
     $hash = md5(microtime());
     // unique cookie hash
     // Fetch User ID :
     $queryUid = $this->db->select("SELECT userID FROM " . PREFIX . "users WHERE username=:username", array(':username' => $username));
     $uid = $queryUid[0]->userID;
     // Delete all previous cookies :
     $this->db->delete(PREFIX . 'sessions', array('username' => $username));
     $ip = $_SERVER['REMOTE_ADDR'];
     if ($rememberme == "true") {
         // User wants to be remembered for a while
         $expiredate = date("Y-m-d H:i:s", strtotime(SESSION_DURATION_RM));
     } else {
         $expiredate = date("Y-m-d H:i:s", strtotime(SESSION_DURATION));
     }
     $expiretime = strtotime($expiredate);
     $this->db->insert(PREFIX . 'sessions', array('uid' => $uid, 'username' => $username, 'hash' => $hash, 'expiredate' => $expiredate, 'ip' => $ip));
     // Check to see if user checked the remember me box
     Cookie::set('auth_cookie', $hash, $expiretime, "/", FALSE);
 }
示例#4
0
文件: Auth.php 项目: Tico973/Auth
 /**
  * Creates a new session for the provided username and sets cookie 
  * @param string $username
  */
 private function newSession($username)
 {
     $hash = md5(microtime());
     // unique session hash
     // Fetch User ID :
     $queryUid = $this->db->select("SELECT id FROM users WHERE username=:username", array(':username' => $username));
     $uid = $queryUid[0]->id;
     // Delete all previous sessions :
     $this->db->delete('sessions', array('username' => $username));
     $ip = $_SERVER['REMOTE_ADDR'];
     $expiredate = date("Y-m-d H:i:s", strtotime(SESSION_DURATION));
     $expiretime = strtotime($expiredate);
     $this->db->insert('sessions', array('uid' => $uid, 'username' => $username, 'hash' => $hash, 'expiredate' => $expiredate, 'ip' => $ip));
     Cookie::set('auth_session', $hash, $expiretime, "/", FALSE);
 }