Solved

Redirect to the page requested before login

Posted on 2009-05-03
2
502 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

752 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