From the first comment in the manual:
Note that this function doesn't (or at least doesn't seem to) actually filter based on the current values of $_GET etc. Instead, it seems to filter based off the original values.
edit
Here's where you would add your call to trim()
:
$_SESSION['foo'] = trim(filter_input(INPUT_POST, 'foo', FILTER_SANITIZE_STRING));