0

I'm using header('Location:' . $somePage) in the PHP app I'm working on and it appears to be working correctly. However, every time I use that it adds to the browser history which is annoying. Specifically, some pages require the user to login before they can see that page's content. So if the user is not logged in, a login panel is presented and they are redirected back to the original page. Again, that is all working correctly. But the page is added to the history every time they log in so when they click the Back button, they may have to go through several (of the same) pages to get back to a previous page.

Is there any way to use header('Location:') without adding to the history? Or is there some other method other than using header ?

I suppose I could do it via JavaScript but the problem with that is the app I'm working on is used by school students. And many of the schools' browsers have JavaScript disabled as a security measure.

Any suggestions?

tvwxyz
  • 195
  • 3
  • 14
  • 3
    But that's their history, then - they got a login page, which is part of the history. You can't overwrite that with PHP. – Qirel Jul 08 '20 at 16:20
  • PHP just creates an HTTP response, it has no influence what the HTTP client does with it, and HTTP doesn’t have a “history”. This is indeed purely a client-side thing and only JavaScript can manipulate it. – deceze Jul 08 '20 at 16:21
  • 1
    Without JS you are very limited. Normally I'd send the login functionality through AJAX and on success refresh the current page. That would make all `$_SESSION` checks true at that point. – user3783243 Jul 08 '20 at 16:22
  • Does this answer your question? [What is the difference between client-side and server-side programming?](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) – Mike Doe Jul 08 '20 at 17:47

0 Answers0