Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Redirect to the page requested before login

Posted on 2009-05-03
2
Medium Priority
?
509 Views
Last Modified: 2013-12-13
Hi experts,
Please help me solve this problem:

Suppose a user tries to access 'http://localhost/dir A/restricted.php' page. Since the user is not logged in, he is redirected to 'login.php' page.
Once the user logs in successfully, he is redirected to the page he previously requsted that is : 'http://localhost/dir A/restricted.php.'

Please help me know, how can i implement this redirection to the previously requested page after the user logs in?

Thanks
0
Comment
Question by:sandhya01
2 Comments
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 250 total points
ID: 24290691
When you check access and decide you need to redirect to login.php, either set a session variable or include the url of the page in the url to login.php. Then in login.php, check if this session/url variable exists, if so, redirect to that page after a successfull login. If you use the url variable emthod, you must also put it as a hidden variable on the login form, and fetch it after login so that you know where to redirect. Remember to use urlencode() when you put an url within the url.
0
 
LVL 10

Assisted Solution

by:stormist
stormist earned 250 total points
ID: 24290749
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question