Reputation: 11
I have created the project which has login page login.blade.php which has only Regno to login-in. once it login is the success it will redirect to home.blade.php and it followed by 4 more pages when clicking of next button in each page page2.blade.php,page3.blade.php,page4.blade.php,page5.blade.php and finally, it should redirect to login page itself. The problem is the browser back button should not allow it to go back to the previous page.
can anyone suggest me how to create middleware for this? thank you.
Upvotes: 0
Views: 88
Reputation: 537
Read this thing. I once implemented in the same way. By setting cache control in response header. https://stackoverflow.com/a/51821808/10239067
Upvotes: 0
Reputation: 17166
The browser's back button is not controlled by the server, where Laravel runs. There is no way for you to block it or interact with it in any way inside your PHP code.
What you can do is send XMLHHTTPRequest
(XHR) with JavaScript. They ensure that on a button click you will stay on the same page in the browser and then your JS-code can read the server response (your rendered page templates) and replace the current content with the one from that response. You can read more on this when you google for AJAX, e.g. this article: https://www.sitepoint.com/use-jquerys-ajax-function/
Upvotes: 1