how to Store User's Last Page Visited using session in php5?
when user come to my website & when he login then he will redirect to user panel of my site. but if user is not active more than 5 min then session will expire that time if user will active then it will redirect to login page.
now i want when user relogin then he will redirect to his last visited page|(where his session expire last time).
Only way to achieve this is by storing the last visited page into the database OR a cookie. You can never know when a session times out and after the timeout any information will be lost. You can also not rely on the REFERRER information as it's up to the browser to send the referer (what happens if a third party site links to you login page?).
Best advise: Use a cookie.
store page in session and then save page in database on sessionEnd
If the session has expired, the last page value won't be there. You could:
This shouldn't be necessary at all.
At the time you redirect the user to the login page, you already know the URL the user requested. Add that URL as a parameter to the login page.