Teng Posted September 13, 2007 Share Posted September 13, 2007 I want it so that when a user tries to say type in a page... userdetails.php and is not logged in it says sorry you are not logged in you will be redirected to the login page in 5 seconds. Atm in my code i have <?php session_start(); ............. ............. if (isset($_SESSION['userid'])) { ............ ............ } else { echo '<p>You are not logged in.</p>'; echo '<p>Only logged in users may see this page.</p>'; } ?> Link to comment https://forums.phpfreaks.com/topic/69145-solved-using-headers-for-timed-redirect-if-user-is-not-logged-in/ Share on other sites More sharing options...
Jessica Posted September 13, 2007 Share Posted September 13, 2007 You have to use meta refresh to do this. Why not just redirect them right away? Link to comment https://forums.phpfreaks.com/topic/69145-solved-using-headers-for-timed-redirect-if-user-is-not-logged-in/#findComment-347551 Share on other sites More sharing options...
Teng Posted September 13, 2007 Author Share Posted September 13, 2007 Yes i suppose i could redirect them straight away but i have it come up with Login Succesful and the time of login... so i wanted them to be able to see that then redirect Link to comment https://forums.phpfreaks.com/topic/69145-solved-using-headers-for-timed-redirect-if-user-is-not-logged-in/#findComment-347570 Share on other sites More sharing options...
Teng Posted September 13, 2007 Author Share Posted September 13, 2007 Hey guys got a solution here thought i'd share it. I ended up using header('Refresh: 5;url=userdetails.php'); Link to comment https://forums.phpfreaks.com/topic/69145-solved-using-headers-for-timed-redirect-if-user-is-not-logged-in/#findComment-347658 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.