Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6255327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:20:43+00:00 2026-05-24T14:20:43+00:00

Been reading a bit to find the answer with not too much luck. I

  • 0

Been reading a bit to find the answer with not too much luck.

I have a site where members can browse the site anonymously but some pages are restricted. I have the members redirected to a login page once they click a link that needs them to be logged in to view.

The problem I’m facing is I don’t know how to redirect the member to the page they were trying to get to once logged in.

They tried to to get to /profile.phtml , it sent them to /login.phtml , now when they log in, I want them to be sent to /profile.phtml because that’s where they clicked to get to. If they clicked /album.phtml, I want them to be sent to /album.phtml after login.

Can anyone help? Do I somehow store the URL in a session?

Much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T14:20:45+00:00Added an answer on May 24, 2026 at 2:20 pm

    Just before making the header("Location:") call to redirect, store the page they’re currently on in $_SESSION['redirect_to']. Upon successful login, make another header() call to redirect back to the original page and unset the session variable so it doesn’t get accidentally reused anywhere.

    $_SESSION['redirect_to'] = $_SERVER['REQUEST_URI'];
    header("Location: http://example.com/login.php");
    exit();
    
    // On successful login
    $redirect = $_SESSION['redirect_to'];
    // unset the session var
    unset($_SESSION['redirect_to']);
    header("Location: http://example.com/$redirect");
    exit();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading about the thread-pool pattern and I can't seem to find
I've been reading up a bit about coffeescript's inheritance model and I have the
I've been reading up about ID-based encryption , but can't find any implementations (the
I've been reading a fair bit about the performance of using LINQ rather than
Out of curiosity, I've been reading up a bit on the field of Machine
I have been reading through the C++ FAQ and was curious about the friend
I have been reading the MSDN documentation on subclassing and I have been successful
I've been reading a bit about functional programming recently and am keen to get
I've been reading up a lot about transactional memory lately. There is a bit
I've been reading quite a bit about Thrift and it looks like a technology

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.