Esempio n. 1
0
 public static function rememberMe($user)
 {
     $token = self::generate_random_128_256_bit();
     // generate a token, should be 128 - 256 bit
     //$u->token = $token;
     //$u->save();
     $cookie = $user . ':' . $token;
     $mac = hash_hmac('sha256', $cookie, getenv("key"));
     $cookie .= ':' . $mac;
     Cookie::set("rememberme", $cookie);
 }
Esempio n. 2
0
 public function setRememberMe()
 {
     //  STEP 1: Generate The Hash.
     $key = rand(1, 100000) . time();
     $hash = Criptography::encript($key);
     //  STEP 2: Store the key/hash combination + the session as JSON Array on the database
     $session = new Sessions();
     $session->hash = $key;
     $session->json_session = json_encode($_SESSION);
     $session->saveAndGetId();
     //Set the cookie with the ID and the cookie with the hash
     Cookie::set(Config::get("cookieID"), $session);
     Cookie::set(Config::get("cookieHash"), $hash);
 }