Welcome Guest, Not a member yet? Register   Sign In
CI4 Best way to ignore specific url in $_SESSION['_ci_previous_url'
#1

(This post was last modified: 07-14-2020, 04:39 PM by Cyto5.)

What is the best way to ignore specific url's from getting added to $_SESSION['_ci_previous_url']. I have a automatic ajax timer logging a users activity and it doesn't get recorded when it goes through a normal ajax request as CI4 filters those out automatically but I also have it update when they leave the page and that get's send using navigator.sendBeacon() which CI4 doesn't register as an ajax request so it ends up adding the ajax time logger url to the $_SESSION['_ci_previous_url'].

if you have to extend the core could you please provide an example of that (I see how to extend in the doc's as an example but not positive how to actually use it for this specific case). I don't see anything I can use/replace in the Common.php file and not sure exactly how to extend the core with how I am using the redirects. Right now I have custom helpers that I use and not sure how I would be able to use or switch those over after extending the core.

PHP Code:
function go($uri '')
{
   return 
redirect()->to($uri);
}

function 
goBack()
{
   return 
redirect()->back();
}

function 
goBackInput()
{
   return 
redirect()->withInput()->back();


Or better yet seems like a config option to ignore uri's (with the wildcards or regex) that would be built into CI4 would be the best option but that would require someone to actually update CI4 with the functionality unless it has it and I am unaware of it?

Thanks for the help.
Reply
#2

Digging into the issue further it looks like the javascript sendBeacon get's counted correctly as ajax when it does a POST but every so often the browser is sendingĀ  GET request at the same time from the same function when it shouldn't be. I started a stack thread specifcally to figure this out https://stackoverflow.com/questions/6292...t-and-post but my original post question is still valid in having a way to filter our specific urls' from getting saved. I tried setting up a "before" filter on the controller to manually set the $_SERVER['HTTP_X_REQUESTED_WITH']) = 'xmlhttprequest' so that whatever url I determine get's flagged as ajax however CI handles this before the filters happen so that didn't work.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB