Stopping User Redirecting via URL


#1

Hi Everyone,

Not even sure if this is possible but basically if a user is on a certain page ie /Controller/currentpage, is there a way keep them on that page until they submit certain information (a few inputs with firstname, lastname and a registration number which is submitted via ajax currently).

Basically, if they try to type a new URL into the address bar while on currentpage, is there a way to prevent them from being able to access that resource?

Alternative is to redirect them back to current page when the navigate away from it via the address bar

Thanks


#2

So basically you want to have them go to /Controller/currentpage and then they’ll be stuck there until they submit their data? (sounds sketchy though, but ah well)

What you could do is create a variable in the session that is on false until they submit the data.
Then, when they have submitted this data, the variable will be set to true.

Everytime the user tries to load a page, check if the variable is true|false.
if true, then can pass, if false redirect them back to /Controller/currentpage


#3

Sketchy? Yeah, but I do what I’m told :-). In any case I did solve it the way you mentioned. Thank you for your help.