示例#1
0
 /**
  * Sets a nonce in the session ['Q']['nonce'] field and in cookie 'Q_nonce'
  * @method setNonce
  * @param {boolean} [$overwrite=false] If true, sets a new nonce even if one is already there.
  */
 static function setNonce($overwrite = false)
 {
     self::start();
     if ($overwrite or !isset($_SESSION['Q']['nonce'])) {
         $_SESSION['Q']['nonce'] = md5(mt_rand() . microtime());
     }
     if (!empty($_SERVER['HTTP_HOST'])) {
         Q_Response::setCookie('Q_nonce', $_SESSION['Q']['nonce']);
     }
     Q_Session::$nonceWasSet = true;
 }
示例#2
0
 /**
  * Sets a nonce in the session ['Q']['nonce'] field and in cookie 'Q_nonce'
  * @method setNonce
  * @param {boolean} [$overwrite=false] If true, sets a new nonce even if one is already there.
  */
 static function setNonce($overwrite = false)
 {
     self::start();
     if ($overwrite or !isset($_SESSION['Q']['nonce'])) {
         $_SESSION['Q']['nonce'] = sha1(mt_rand() . microtime());
     }
     if (!empty($_SERVER['HTTP_HOST'])) {
         $durationName = self::durationName();
         $duration = Q_Config::get('Q', 'session', 'durations', $durationName, 0);
         Q_Response::setCookie('Q_nonce', $_SESSION['Q']['nonce'], $duration ? time() + $duration : 0);
     }
     Q_Session::$nonceWasSet = true;
 }