Пример #1
0
 /**
  * Validates the session throwing a SessionValidationException if there is an invalid property in the exception
  *
  * @param   boolean  $restart  Reactivate session
  *
  * @return  void
  *
  * @since   __DEPLOY_VERSION__
  */
 public function validate($restart = false)
 {
     if ($restart) {
         $this->session->set('session.client.forwarded', null);
     }
     $xForwardedFor = $this->input->server->getString('HTTP_X_FORWARDED_FOR', '');
     // Record proxy forwarded for in the session in case we need it later
     if (!empty($xForwardedFor) && filter_var($xForwardedFor, FILTER_VALIDATE_IP) !== false) {
         $this->session->set('session.client.forwarded', $xForwardedFor);
     }
 }
Пример #2
0
 /**
  * Validates the session throwing a SessionValidationException if there is an invalid property in the exception
  *
  * @param   boolean  $restart  Reactivate session
  *
  * @return  void
  *
  * @since   __DEPLOY_VERSION__
  * @throws  InvalidSessionException
  */
 public function validate($restart = false)
 {
     if ($restart) {
         $this->session->set('session.client.address', null);
     }
     $remoteAddr = $this->input->server->getString('REMOTE_ADDR', '');
     // Check for client address
     if (!empty($remoteAddr) && filter_var($remoteAddr, FILTER_VALIDATE_IP) !== false) {
         $ip = $this->session->get('session.client.address');
         if ($ip === null) {
             $this->session->set('session.client.address', $remoteAddr);
         } elseif ($remoteAddr !== $ip) {
             throw new InvalidSessionException('Invalid client IP');
         }
     }
 }