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 4586230
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:36:35+00:00 2026-05-21T21:36:35+00:00

I have a problem similar to this one , but slightly different. I have

  • 0

I have a problem similar to this one, but slightly different.

I have it structured like this:
The page the user wants to go to is something like displayData.php. This is the page they should end up back on. This page checks to see if you are logged in and the session isn’t expired like so:

if ($_SESSION["loggedIn"] != "YES")
{
  header ("Location: ".$baseURL."timeout.php");
  exit();
}

On timeout.php, I check the referrer:

<?php
session_start();
$_SESSION['redirect'] = $_SERVER['HTTP_REFERER'];
$_SESSION["errorMessage"] = "Your session has timed out or<br>you have not logged in correctly.";
header ("Location: index.php");
exit();
?>

The problem arises after the user submits the login form and the login page check to see if there is a referrer. We already determined they have the correct login information, however.

if(isset($_SESSION['redirect'])){
    header ("Location: ".$_SESSION['redirect']);
}else{
    header ("Location: menu.php");
}

I would think that logically, when the timeout page sets the variable with $_SERVER['HTTP_REFERER'];, it would set it to the page that redirected to timeout.php, in this case displayData.php. However it seems that instead, it sets it to the referrer of displayData.php (which could be anything, but it is not what we want to send the user to).

Is this the intended effect of HTTP_REFERER, to not update if there was a header redirect? If so, that sucks and i need to rewrite about 80 files to change the login/timeout system. I hope there would be an easier way. We would have done this in a function based system, but we are currently trying to extend legacy code.

Thanks much.

Edit:

To be slightly more clear here.
Think of it in a folder, /admin/. displayData.php is one of many files that can be accessed only by logging in (So we don’t know what specific page they were trying to access when it detected they weren’t logged in). Every one of these pages redirects to timeout.php when the session expires (or if there wasn’t a session at all), therefor I want timeout.php to be able to determine the page that was previously accessed without a session, and then save that information so it can be used later to redirect the user back to the original page they requested on our site.

The reason I want to do it through the timeout.php file is because there are many files just like displayData.php, and I don’t want to edit every single one of them to improve the system if i don’t have to, for the time being.

If this still isn’t clear enough, let me know.

  • 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-21T21:36:35+00:00Added an answer on May 21, 2026 at 9:36 pm

    HTTP_REFERER is intended to be purely informational and is set by the browser not the server. This means that it can be blank or something else entirely. It can also be manipulated by the user. It’s best not to rely on it if possible.

    Why not just set $_SESSION['redirect'] when you’re actually on a page before it redirects to the session check script? For that matter why redirect at all? You could include the timeout.php almost unmodified in the script and use the $_SERVER['PHP_SELF'] variable to determine what $_SESSION['redirect'] should be set to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem very similar to this one , but slightly more involved.
I have similar problem to one discussed here , but with stronger practical usage.
I have asked a similar question to this one already but I think it
My current problem is very similar to this one . I have a downloadFile(URL)
Hey, I have a problem similar to this one ( click ). Approx 2
I have seen few questions similar to this one, but I wanted to make
I have a problem similar to this one: How can I execute code after
I’m having a setTimeout problem similar to this one . But that solution doesn't
My question is similar to this one , but is different enough that I
I have a problem similar to this question but with an added complication: MySql,

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.