Koobazaur Posted July 9, 2007 Share Posted July 9, 2007 Hey, I am working on a user management system and each pageload one of my included files verifies that the session hasn't expired. If it has, it should redirect back to login page. I use header("Location: http://me/login.php") for this and while it does redirect, it works really weird. For instance, if I get redirected to the login page and check page source, I see the code from the previous page (although displayed in my browser is the login page)! Also, after logging in, you should get either redirected to a default page OR the page you were at before. I use header("Location: ") for that as well and every time I get re-directed to default page. I've done shitloads of testing and my code structure is alright - it gets to the proper header and inputs the proper page url to redirect. Yet, the page that loads is the default login page... Case in point: header is being reeeaaallly weird, or I am not using it correctly. Any idea what I am doing wrong? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 9, 2007 Share Posted July 9, 2007 try adding on exit(header("location: http://me/login.php")); that way it will stop executing the current page and move to login.php. Also login.php should really only be the form/maybe a few trackers so don't load it down with php Quote Link to comment Share on other sites More sharing options...
Koobazaur Posted July 9, 2007 Author Share Posted July 9, 2007 try adding on exit(header("location: http://me/login.php")); that way it will stop executing the current page and move to login.php. Also login.php should really only be the form/maybe a few trackers so don't load it down with php I have put die() right after header and now my pages redirect correctly. However, I still get a wrong source code for the page as described... As for not overloading login.php, on the contrary. It is not just a login form, but it's a full login/logout handling file that uses my predefined cUser class that (in turn) handles all my Session and Userdatabase handling. As it is, whenever there is something that happens to my User, I just redirect to login.php and it handles it. Logging in, Logging out, re-authenticating if a session expires (and then sending user back where he left off) are all the things that my login.php takes care of and, once he examines all the cases, it prints out a login form with any errors that may have happened (like invalid user/name pass, outside login attempt blocked etc.) Though I am planning to convert it into it's own include .php file that just does all that and sets a few globals (like, did login succeed or where to redirect after successful login etc.) so I create login forms/handling wherever I want on my website. Quote Link to comment Share on other sites More sharing options...
Koobazaur Posted July 9, 2007 Author Share Posted July 9, 2007 *Bump* Any idea? Quote Link to comment 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.