Solved

Redirect to the page requested before login

Posted on 2009-05-03
2
498 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 125 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 125 total points
ID: 24290749
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now