Redirect user to login page using php

If one user logs out from the page he must not be able to access other pages, and must be directed to log in page. How do I redirect one user after log out to the "log_in" page, using php? Solution: In the log_out.php you firstly destroy all sessions, then using a header e.g.: "header('Location: index.php');" you force the user to be redirected to the log_in.php or by " echo <script>window.location.assign('log_in.php')</script>". I have applied the second way


Had to deal with a similar thing myself. I dislike the 2nd solution, as this is client based (and requires the client to have JS turned on). The first solution is server sided redirect which i definitely prefer.
Klaus Nigsch - Sun, 11/25/2018 - 12:14 :::
Good, short, and straight on point answer. The first solution should be preferred in my opinion, because it uses the features of the technologies in the way they are meant to be used (destroying a session and using a location header for changing location)
Boian Velitchkov - Sun, 12/02/2018 - 18:04 :::
1 answer