protected function TfaTrustedBrowser::setTrusted in TFA Basic plugins 7
Store browser value and issue cookie for user.
Parameters
string $value:
string $name:
2 calls to TfaTrustedBrowser::setTrusted()
- TfaTrustedBrowser::finalize in includes/
tfa_trusted_browser.inc  - TfaTrustedBrowserSetup::submitSetupForm in includes/
tfa_trusted_browser.inc  - @copydoc TfaSetupPluginInterface::submitSetupForm()
 
File
- includes/
tfa_trusted_browser.inc, line 103  - classes for TFA basic plugin
 
Class
- TfaTrustedBrowser
 - Class TfaTrustedBrowser
 
Code
protected function setTrusted($value, $name = '') {
  // Store id for account.
  $record = array(
    'uid' => $this->context['uid'],
    'value' => $value,
    'created' => REQUEST_TIME,
    'ip' => ip_address(),
    'name' => $name,
  );
  drupal_write_record('tfa_trusted_browser', $record);
  // Issue cookie with ID.
  $cookie_secure = ini_get('session.cookie_secure');
  $expiration = REQUEST_TIME + $this->expiration;
  setcookie($this->cookieName, $value, $expiration, '/', $this->domain, empty($cookie_secure) ? FALSE : TRUE, TRUE);
  $name = empty($name) ? $this
    ->getAgent() : $name;
  watchdog('tfa_basic', 'Set trusted browser for user UID !uid, browser @name', array(
    '@name' => $name,
    '!uid' => $this->context['uid'],
  ), WATCHDOG_INFO);
}