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>'; } ?> Quote 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? Quote 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 Quote 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'); Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.