/** * Retrieve the CSRF token for the current request. * * @return string The CSRF token */ private static function token() { if (static::$token !== null) { return static::$token; } $token = Str::random(32); // Store the new token Session::set(self::SESSION_KEY, $token); return static::$token = $token; }
/** * Create a new request for the application. */ public function __construct() { $this->router = new Router(); $this->method = strtoupper($this->router->requestMethod()); // Store the raw input data $input = array_merge($_GET, $_POST); $this->rawInput = new Input($input); // Escape the input data, and store it again $input = $this->escapeInput($input); $this->input = new Input($input); // Store the current URI if (isset($_SERVER['REQUEST_URI'])) { $this->uri = $_SERVER['REQUEST_URI']; } // Retrieve the previous URI from the session, and store it // against the request object if (($previous = Session::get('previous_uri')) !== null) { $this->previousUri = $previous; } // Update the previous URI session key now that we have retrieved // it's value Session::set('previous_uri', $this->uri); }