Redirect to page with data without a route

using a route one can redirect to another page and provide some data as php vars. is that possible without a route as well - like at the head of a template? the go()-helper takes no data, right?

You can either store the data in the session or pass the data along as parameters of the get request.

the data is not ideal for post-vars. a json would have be better. but i can solve it now. thanks.

just to make sure I get this right…

  • when using go() with parameters its on the server only and the browser of the user does never see these parameters?
  • toolkit session or php sessions in general are also only accessible by my php code (unless i set cookies etc).

No, if you use parameters in the URL you pass to go, these will be visible to the user in the browser address line, just as in any GET request.

As regards session security, maybe this is helpful: PHP: Sessions und Sicherheit - Manual

docs say ‘returning data for the template’… so the $foo var is not accessible in controller? any trick how to get it still? magic $data-array? calling a method?

function() {

  // additional data for the page
  $data = array(
    'foo' => 'bar'
  );

  return array('some/page', $data);
}

You can get the data in your controller using the $args parameter: https://getkirby.com/docs/developer-guide/advanced/controllers#arguments-from-the-router

1 Like

if anybody needs it in controller…

<?php

return function($site, $pages, $page, $args) {

  // $args contains all arguments from the current route
 if($foo = a::get($args, 'foo')) { }

};
2 Likes