I have also been thinking about this, the only way that I can think of is:
1. On every page save the url in $_SESSION['current_page'] (not on the login page though).
2. Then when the user visits a restricted area they will login.
3. If login successful then redirect to the $_SESSION['current_page']
Thanks Dex. Does anyone know of a way of doing this without starting a session? I'd like to only start a session if the users are logged in, this will cut down on lurkers starting sessions (I don't know if this will affect performance or not).
If I use $_SERVER['HTTP_REFERER'], and the loggin fails, say they slip a wrong keystroke, then it is lost without it being set as a session variable.
You will need to use sessions or a cookie (sessions is better). Don't worry about the overhead, it is minimal to the point of insignificance. You only need to start the session when the user visits the restricted page, and you will presumably be starting one when they log in anyway.
Last edited by Mindzai; 06-17-2010 at 10:15 AM.
The first rule of Tautology Club is the first rule of Tautology Club.
You will need to use sessions or a cookie (sessions is better). Don't worry about the overhead, it is minimal to the point of insignificance. You only need to start the session when the user visits the restricted page, and you will presumably be starting one when they log in anyway.
Bookmarks