I have a CodeIgniter site that assigns users a UUID when the landing page is hit. Reloading the landing page will assign a new UUID, but once you start progressing through the forms your UUID remains the same. However something is happening I don't quite understand when the user hits the back button, and the behavior is different depending on what URL they arrived with?
Case 1: domain.com/somehash?key=value
OR domain.com/somehash/
If you arrive with the above url containing a GET parameter, submit the first form (which contains your uuid), and press the back button, you return to the landing page but your UUID does not change.
Case 2: domain.com/somehash
With no GET parameters, if you submit the first form (which contains your uuid) and press the back button, you return to the landing page and receive a NEW uuid.
I tested this in the latest Chrome and Firefox, is it linked to some kind of caching strategy they implement? Ideally hitting back would NOT refresh the page.
EDIT: I should note we can't use cookies for this tool, so sessions are out
Further edit: Simply going to domain.com/
, adding a backslash, stops the UUID from refreshing when hitting the back button. Possibly related to CodeIgniter routes.php or .htaccess?
Relevant .htaccess entries:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [L]
Routes.php:
$route['default_controller'] = "home";
$route['404_override'] = '';
$route['(:any)'] = 'home/index/$1';
Try setting these headers and see if that makes the behavior consistent in both scenarios:
$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->output->set_header("Cache-Control: post-check=0, pre-check=0");
$this->output->set_header("Pragma: no-cache");
$this->output->set_header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
More info: http://ellislab.com/codeigniter/user-guide/libraries/output.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With