Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder stevenmw's Avatar
    Join Date
    Jun 2007
    Location
    OK
    Posts
    497
    Thanks
    27
    Thanked 31 Times in 31 Posts

    Best solution to send a user back to previous page after usubmitting login form

    I have a login form, and once you login successfully it takes you to one set page every time. In your opinion what would be the best way to redirect a user back to the page they were at before logging in?

    I thought about

    PHP Code:
    $_SERVER['HTTP_REFERER'
    But a couple of desktop and internet browsers offer an option to turn of sending referrers. Then I thought about submitting the current url in a hidden form and using it to redirect to. Then I thought about saving it in the session, but that has draw backs if a user ends up saving multiple pages.

    Does any one have any good suggestions?
    Thanks!

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,089
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Put the value in the form. That will defeat the browser not sending the referrer and also the session issue.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #3
    Regular Coder stevenmw's Avatar
    Join Date
    Jun 2007
    Location
    OK
    Posts
    497
    Thanks
    27
    Thanked 31 Times in 31 Posts
    tangoforce, do you mean something like

    Code:
    <input type="hidden" name="return" value="<?php echo($_SERVER['REQUEST_URI']); ?>
    Thanks!

  • #4
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,089
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Yup
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #5
    Regular Coder stevenmw's Avatar
    Join Date
    Jun 2007
    Location
    OK
    Posts
    497
    Thanks
    27
    Thanked 31 Times in 31 Posts
    Are there any major problems with

    PHP Code:
    $_SERVER['REQUEST_URI'
    like there are with

    PHP Code:
    $_SERVER['HTTP_REFERER'
    Thanks!

  • #6
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,089
    Thanks
    51
    Thanked 506 Times in 493 Posts
    No. The request URI is what the browser requested in the request headers - it will always be present unlike the referrer.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • Users who have thanked tangoforce for this post:

    stevenmw (01-24-2013)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •