Remember what was clicked before login
How can I remember what was clicked when:
1) the user is browsing
2) clicks a restricted (members only) page
3) logs in
4) I want them to go back to the restricted page if login is successful
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']
I have also come across $_SERVER['HTTP_REFERER'], not sure if this will work though:
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 11:15 AM.
Ok. Thanks to both of you.
Originally Posted by Mindzai
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)