I want to be able to test a website I am building using PHP that gets all its content from a database that uses point in time. I have a series of pages that I use to maintain the content and assign effective dates.
The live website will not have access to a session.
I simply want to hack the URL with a parameter like so:
mywebsite.com/current.php?asof=2016-01-01
But I want this parameter to appear on all subsequent pages.
I could use cookies I guess but I want the visual cue.
Finally, some of the pages I navigate to will have additional parameters.
Can this be done? If so, how?
EDIT: Is there a way to edit the response by injecting URL parameters for any arbitrary response.
Set your cookie and then for every link you can do something like the following:
<?php
$asof = (isset($_COOKIE['asof']) ? 'asof=' . $_COOKIE['asof'] : '');
?>
<a href="/current.php?<?=$asof?>">link</a>
If navigation is done only via links and forms, and you have no session, you could try injecting the params into all links and forms before rendering the html.
// set the asof value once upon starting navigation
$_GET['asof'] = '2016-01-01';
// then on all pages onward
// grab all links and inject all $_GET params
$html = preg_replace('/(href="[^"]+)"/', '$1?'.http_build_query($_GET).'"', $html);
// the same for forms
$html = preg_replace('/(action="[^"]+)"/', '$1?'.http_build_query($_GET).'"', $html);
echo $html;
This gets all the data passed in the query string ($_GET) and injects it into all links and forms. So every click on a link will propagate the $_GET params. Keep in mind that this is a rough implementation. This doesn't take into account links that already have query strings or pasting the url.